error in programme
You have Dim a(10) As Single, which will reserve up to 10 elements in
the array, but your For loop goes up to 100, so it will fail when
i=11. Just change it to Dim a(100) ...
max, min, sum and average are reserved words, so you might also think
about changing these names (eg to my_max, my_min etc) to avoid
confusion.
Hope this helps.
Pete
On Jul 26, 7:42 pm, biker man wrote:
the programme i wrote is to return the maximum, minimum and average
of
100 numbers. But it keeps returning an error. Does anyone no whats
wrong with it? what its missing?
cheers
Sub testing()
Dim a(10) As Single, max As Single
Dim min As Single, sum As Single
Dim Average As Integer, i As Integer
n = 100
max = a(1)
min = a(1)
sum = a(1)
For i = 1 To 100
If max a(i) Then max = a(i)
If min < a(i) Then
min = a(i)
End If
sum = sum + a(i)
Next i
Average = sum / n
End Sub
|