listbox

Simon4VB

Member
Joined
Apr 2, 2009
Messages
23
Programming Experience
1-3
I have managed a listbox with two columns (the items and their quantities)
I am trying to sum up all the qtys together for a grand total, but cannot manage. I tried with listviewitem.contains and listviewitem. items. Now I'm lost.
 
Last edited:
First up, please post in the forum most appropriate for the topic. VS.NET is for IDE issues. If you have an issue with Windows Forms Controls then the Windows Forms forum is the appropriate place to post. Moved.

As for the question, a ListBox is not the same thing as a ListView. You first need to decide which one you're actually using.
 
Each "cell" in a ListView is a ListViewSubItem in a ListViewItem and each of those has a Text property that returns the String displayed in that cell. You need to get the Text of each of the subitems in the second column, convert that to a number and add it to a running total. You'll use a For Each loop to loop through the Items in the ListView. To get a number from the second column you'll use something like:
VB.NET:
CInt(myListViewItem.SubItems(1).Text)
I'll leave it to you to put the pieces together.
 
Back
Top