|
-
Apr 25th, 2001, 04:15 PM
#1
Thread Starter
Hyperactive Member
Summing an Array
I have an array that contains the numbers (1,2,3,4). When I use the code below to sum the array, I get sum[arr(0)] = 1, sum[arr(0)+ arr(1)] = 12, sum[arr(0)+ arr(1) + arr(2)] = 123, sum[arr(0)+ arr(1) + arr(2) + arr(3) ] = 1234. Why are the numbers being appended to each other instead of being summed? Note: I am using arr(index,1) because I have a 2-dimensional array.
================================
If IsMissing(First) Then First = LBound(arr, 1)
If IsMissing(Last) Then Last = UBound(arr, 1)
For index = First To Last
If IgnoreEmpty = False Or Not IsEmpty(arr(index, 1)) Then
countcol1 = countcol1 + 1
sumcol1 = sumcol1 + arr(index, 1)
End If
Next
End If
End If
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|