|
-
November 19th, 2004, 08:27 AM
#1
Average?
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
------------------------------------------------
-DOES IT ALL SOMETIMES GET A BIT CONFUSING-
------------------------------------------------
-
November 19th, 2004, 09:30 AM
#2
Re: Average?
little_boy,
assuming your last post example, something like this
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
Hope it helps (rate the post if it does)
Did it help? rate it.
The best conversation I had was over forty million years ago ... and that was with a coffee machine.
-
November 19th, 2004, 10:29 AM
#3
Re: Average?
thanks works lovely to what i want....
thanks again
------------------------------------------------
-DOES IT ALL SOMETIMES GET A BIT CONFUSING-
------------------------------------------------
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|