I have an array that has accumulated values (integers) and I want to sum them up. How would you do that in Lotusscript?
Thank you,
KB
I have an array that has accumulated values (integers) and I want to sum them up. How would you do that in Lotusscript?
Thank you,
KB
Subject: How do you sum values in a single dimensional array?
'NOTE: This assumes that your arrays are zero-based. That is, Option Base 0
'Declare an integer array with four elements.
Dim intArray(3) as integer
'Declare a long integer.
'NOTE: 'Use a long integer in case your sum exceeds 32,768
Dim lngSum as Long
'Declare a helper variable.
Dim I as integer
'Assign values to the array elements.
intArray(0) = 88
intArray(1) = 191
intArray(2) = 94
intArray(3) = 0
'Initialize our summing variable.
lngSum = 0
'Iterate through the array, summing the values.
For I = LBound( intArray ) to UBound( intArray )
lngSum = lngSum + intArray( I )
Next
msgbox Cstr( lngSum )
'NOTE: I think that Turbo Pascal used to provide an array-summing function. Dot-Net may as well.
Subject: How do you sum values in a single dimensional array?
Assume Array is your numeric array.
Total = 0
for j% = lbound(Array) to ubound(Array)
Total = Total + Array(j%)
next
Subject: How do you sum values in a single dimensional array?
Subject: RE: How do you sum values in a single dimensional array?
Excellent! Thanks alot everyone for your input. Appreciate it.
KB