Joseph Witchard
02-24-2008, 05:36 PM
I'm trying to write code for my Visual Basic class to calculate the average of a double array names "rates".
For subscript As Integer = 1 To rates.Length – 1
Accumulator = Accumulator + Rates()
Rates(subscript) = Rates(subscript) + 1
Counter = Counter + subscript
Next subscript
Average = Accumulator / Counter
Me.xAverageLabel.Text = Convert.ToString(Average)
That was the best I could come up with, but even so, it doesn't look right to me. Anyone who has some experience with Visual Basic, I'd appreciate the help.
For subscript As Integer = 1 To rates.Length – 1
Accumulator = Accumulator + Rates()
Rates(subscript) = Rates(subscript) + 1
Counter = Counter + subscript
Next subscript
Average = Accumulator / Counter
Me.xAverageLabel.Text = Convert.ToString(Average)
That was the best I could come up with, but even so, it doesn't look right to me. Anyone who has some experience with Visual Basic, I'd appreciate the help.