Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help someone

Status
Not open for further replies.

jimmpy

Technical User
Joined
Nov 25, 2000
Messages
3
Location
GB
I need some help with writting a program that :
asks for 15 integrers and afterwards displays the maximum, minimum and
average of the 15 values.

The program has to be written in vb 6.

james
 
Here goes:

Dim i As Integer
Dim lMax As Long
Dim lMin As Long
Dim lTotal As Long
Dim lRetVal As Variant
Dim sMsg As String
Dim bBegin As Boolean
bBegin = True

For i = 1 To 15
Do While (Not IsNumeric(lRetVal) Or bBegin = True) Or InStr(lRetVal, ".") > 0
lRetVal = InputBox("Please enter an integer number " & i)
bBegin = False
Loop
If i = 1 Then
lMin = lRetVal
lMax = lRetVal
End If
If lRetVal < lMin Then lMin = lRetVal
If lRetVal > lMax Then lMax = lRetVal
lTotal = lTotal + lRetVal
bBegin = True
lRetVal = &quot;&quot;
Next i

sMsg = &quot;Minimum = &quot; & lMin
sMsg = sMsg & vbCr & &quot;Maximum = &quot; & lMax
sMsg = sMsg & vbCr & &quot;Average = &quot; & (lTotal / 15)
MsgBox sMsg


Simon
 
thank you ever so much
happy.gif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top