add numbers in string

B

billypit786

String=1000;2000;3000;4000

how can i add this nos?

i need this
total = 1000+2000+3000+4000=10000
 
L

Linq Adams via AccessMonster.com

As answered in TheScripts.com:

Assuming you have the Split() function available (I think it started with
version 2000)

YourString ="1000;2000;3000;4000"
Nos = Split(YourString,";",-1)
YourTotal = val(Nos(0)) + val(Nos(1)) + Val(Nos(2)) + val(Nos(3))
 
D

Douglas J. Steele

There's a simpler way:

YourString ="1000;2000;3000;4000"
YourTotal = Eval(Replace(YourString, ";", "+"))
 
Top