can u pass an idea... is this is possible to plus all that items(Integer) that are in listbox or listview...
e.g a list box have 4 items...
1)-20
2)-40
3)-80
4)-100
is this possible to plus these items,??? items also can b infinite, depends upon user...i dont have any idea, and could not find thing regarding this on internet

is this is possible to plus all that items(Integer) that are in listbox or listview...

Yes, you can.

For listbox :

Dim i, result As Integer
For i = 0 To List1.ListCount
    result = result + List1.List(i)
Next i
MsgBox result

For Listview :

Dim i, result As Integer
For i = 1 To ListView2.ListItems.Count
    result = result + ListView2.ListItems(i).SubItems(1)
Next i
MsgBox result

The above code will not execute 100%. Add a minus 1 after the count -

For i = 0 To List1.ListCount - 1 'Here, otherwise it will skip the first record

For i = 1 To ListView2.ListItems.Count - 1 'Here as well...

:)

@ Andre : thanks for the correction about listbox (you right index in lisbox start with 0) but i'm not sure about listview. if you minus listitems.count with 1 then it will skip the last item when you adding the items.

Edited 5 Years Ago by Jx_Man: n/a

With a listview, you need to determine if there are headers or not, then deduct the header line and start reading from the following line.:)

Goooood......i had not headers,. thats why both codes of Jx were working fine without minus "-"....
Thanks Andre for Correction.

This question has already been answered. Start a new discussion instead.