|
Adding contents of a list box
I'm enrolled in VB.net at a local community college. We're using Visual Basic 2005 Text Book.
My assignment is to create a form that does several things which was easy until I came to this part . . .
Add the contents of the ListBox and show the total in a label.
If there were only 2 items it would be easy, but there is a varying number of items.
Chapter 5 also deals with loops so I'm thinking of using a For . . .Next loop.
I can get the number of items in the list box into a label but I am REALLY stuck on totalling all the numbers in the list box.
Example:
In lstTotals there are 5 items in lstCosts
250
525
375
600
125
and here is what I have so far, which isn't working:
intListSize = lstCosts.Items.Count - 1
For intCount = 0 To intListSize
decTotalCosts = lstCosts.Items(intCount)
intCount += 1
Next intCount
lblTotalCost.Text = decTotalCosts
What am I missing here?
Thank you in advance.
|