hi all does someone know how to work an average out....using a list box...its getting me confused...it needs to work out the total of all the numbers entered and divide by itself....
thanks
Printable View
hi all does someone know how to work an average out....using a list box...its getting me confused...it needs to work out the total of all the numbers entered and divide by itself....
thanks
little_boy,
assuming your last post example, something like this
Hope it helps (rate the post if it does)Code:Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim i As Integer
Dim d As Double
d = 0
For i = 0 To ListBox1.Items.Count - 1
If CDbl(ListBox1.Items(i)) >= CDbl(TextBox1.Text) AndAlso CDbl(ListBox1.Items(i)) <= CDbl(TextBox2.Text) Then
ListBox2.Items.Add(ListBox1.Items(i))
d += CDbl(ListBox1.Items(i))
End If
Next i
ListBox2.Items.Add("Average: " + CStr(d / ListBox2.Items.Count))
End Sub
thanks works lovely to what i want....
thanks again