Calculate average of numbers in a ListBox in Visual Basic 2015 |
Here is the source code:
Dim AllNumbers As Double = 0
Dim Current As Double = 0
Dim Average As Double = 0
For i As Integer = 0 To ListBox1.Items.Count - 1
AllNumbers += Val(ListBox1.Items(i))
Current += 1
Next
Average = AllNumbers / Current
TextBox2.Text = Average.ToString
No comments:
Post a Comment