determine highest number and lowest number in array

Category: Latest Topics    |    3 views
this is my code

Private Sub Command1_Click()
Dim maximum, minimum, highest, lowest As Integer
Dim num(1 To 5), i, j, z As Integer

    For i = 1 To 5
        num(i) = InputBox("number")
    Next i
    
    highest = num(1)
    lowest = num(1)
    
    For z = 1 To 5
        If num(z) > highest Then
            highest = num(z)
        End If
    Next z
    
    For j = 1 To 5
        If num(j) < lowest Then
            lowest = num(j)
        End If
    Next j
    
    Print "Highest is : "; highest
    Print "Lowest is : "; lowest

End Sub

whenever i enter numbers in the input box with this sequence : 4, 4, 44, 4, 5
the result of the highest number will be 5
same if i enter in this sequence : 4, 44, 4, 5 or 5, 5, 55, 6
anybody can help??

Share/Save/Bookmark

1 Star2 Stars
Loading ... Loading ...

0 responses so far!

Leave a Comment

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word