Click to See Complete Forum and Search --> : Add numbers


Ace Jones
April 7th, 2001, 03:52 PM
Hi Everyone,

I have added a ListView control to a form with 4 columns. I would like to add the numbers together that are in column 2 to come up with a total for that column. Does anyone have any ideas how to go about accomplishing this? I would appreciate any help. Thank you.

John G Duffy
April 8th, 2001, 06:28 PM
This should do what you are trying to do. THe sample assumes the column to Total is Column 2
---> Subitems(1)

private Sub Command1_Click()
Dim x as Integer
Dim Total as Long
for x = 1 to listView1.ListItems.Count
Total = Total + CLng(lv.ListItems(x).SubItems(1))
next x
MsgBox Format(Total, "###,###,###,##0")
End Sub




John G