|
-
Aug 9th, 2012, 04:31 AM
#1
Thread Starter
Fanatic Member
Add items in listview subitem?
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
-
Aug 9th, 2012, 05:12 AM
#2
Re: Add items in listview subitem?
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.
-
Aug 9th, 2012, 05:23 AM
#3
Re: Add items in listview subitem?
Moved From The CodeBank (which is for sharing code rather than posting questions )
-
Aug 9th, 2012, 05:59 AM
#4
Re: Add items in listview subitem?
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.
-
Aug 9th, 2012, 06:33 AM
#5
Re: Add items in listview subitem?
 Originally Posted by jmcilhinney
Hmmm... I found this thread in the New Posts section and thought it was in the VB.NET forum.
I had a feeling that is what you might have been thinking. 
Jamie: Try something like
Code:
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
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
|