Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27329

[RESOLVED] Sum of items in listbox

$
0
0
Hello,

I have a program that I've created a Do While loop counting to 100 in 5s. I get the results perfectly, but now I am trying to add the sum of all the numbers in the box and display in a label. I get the number 100 in the label - but that's not the sum of all the numbers in the textbox. The code is what I have below:

Public Class Form1

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim number As Integer

number = -5
Do While number <= 95
number = number + 5
ListBox1.Items.Add(number)
Loop

For Each sumTotal As String In ListBox1.Items
Label1.Text = sumTotal
Next

End Sub
End Class

Any suggestions on how to fix the sum/label issue?

Thanks!

Viewing all articles
Browse latest Browse all 27329

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>