Pages

Wednesday, March 2

Find the highest number in the array

'This code demonstrate how to find the highest number in a numaric array.
 
Dim num, i, Length1

num=array(34,12,98,43,89,49,56)
Length1 = UBound(num)    'Find the length of array

For i= 1 to Length1
 If (num(i) < num(0)) Then  'to find lowest number, just change it to >
    num(0)=num(i)
 End If
Next

MsgBox num(0) 'Highest Number