Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 28
Default programme error

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default programme error

You don't put anything into the array a.

You set the upper bound of a to 10 and then try and loop 1 to 100, trying to
get that item within a (which doesn't exist after 10).

and you declare Average as Integer, but it is most likely to have a decimal
part, so you should declare it as Double.


--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"paul" wrote in message
oups.com...
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



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
run programme error occuring harry buggy Excel Worksheet Functions 2 September 11th 07 12:18 PM
error in programme biker man Excel Discussion (Misc queries) 4 July 26th 07 09:01 PM
programme error paul[_17_] Excel Programming 1 July 26th 07 05:46 PM
Error message Microsoft Graph is part of another programme Alimyb Setting up and Configuration of Excel 0 August 14th 06 11:28 AM
Error when loading a programme from a tool bar Vacation's Over Excel Programming 1 October 18th 05 04:15 PM


All times are GMT +1. The time now is 12:53 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"