Hi, Is it possible to add up all the numbers in a listview sub item? For example column 3 has
1
2
3
8
is it possible to make a label display the total by adding the numbers up?
Regards
Jamie
Printable View
Hi, Is it possible to add up all the numbers in a listview sub item? For example column 3 has
1
2
3
8
is it possible to make a label display the total by adding the numbers up?
Regards
Jamie
Loop through the items and, on each iteration, get the Text of the appropriate subitem and convert it to a number, then add that number to a running total. That running total would obviously be initialised to zero and, at the end of the loop, it contains the total for the column.
Moved From The CodeBank (which is for sharing code rather than posting questions :) )
Hmmm... I found this thread in the New Posts section and thought it was in the VB.NET forum. Apparently I can't see straight. If it's a VB6 ListView then the details may be a bit different to what I suggested but the principle will be the same.
I had a feeling that is what you might have been thinking. :)
Jamie: Try something likeCode:Dim i As Long
Dim lngTotal As Long
For i = 1 To Listview1.ListItems.Count
lngTotal = lngTotal + Val(Listview1.ListItems(i).SubItems(3))
Next
'do something with lngTotal