Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Summing digits in a number
Message
 
 
To
07/12/2002 22:52:56
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00730694
Message ID:
00730695
Views:
8
>Hi. Is there a function (in Fox) that will sum the digits in a number? I need to create a hash total for my electronic bank data.
>
>Thanks, Randy

No native function. You can write your own, though, like this (probably not the best algorithm):
lnNumbers=12345678901000
lcStr = alltrim(padr(m.lnNumbers,100))
lnSum = 0
for lnI=1 to len(m.lcStr)
  lnSum=m.lnSum+val(substr(m.lcStr,m.lnI,1))
next
If it's not broken, fix it until it is.


My Blog
Previous
Reply
Map
View

Click here to load this message in the networking platform