In LS i have a requirement to add totals returned from a multidimensional array. My array looks like this:
jose, date, 4
jose, date, 3
jim, date, 4
jack, date, 1
johnny, date, 1
johnny, date 1
what i am trying to get as output is an array which combines the entries in the first array that have the same name. date will not be passed to the second array. it is only there for usage in another place in the script prior to this. my goal is to get a total for each person so that the output is as below:
jose, 7
jim, 4
jack, 1
johnny, 2
I would appreciate any help in this matter. On a side note, I would like to point out that I am NOT an alcoholic.
Subject: Adding values in multidimensional arrays
Well, you may be one before this is over ;o)
Looks to me like you want to create a List as an intermediate step:
Dim listTotals List As Integer
Use the names as list tags, so when you are putting the totals together:
If Iselement(listTotals(name)) Then
listTotals(name) = listTotals(name) + newValue
Else
listTotals(name) = newValue
End If
You may be able to use the list as-is, but you can always turn it into an array if you need to.
Subject: RE: Adding values in multidimensional arrays
Thanks. I figured this would be the route… was trying to save a step if I could. I’ll work through it, without the tequila.