Tuesday, May 18, 2010

Find largest and smallest values in an array

Dim arr(6)
arr(0)=44
arr(1)=32
arr(2)=99
arr(3)=7
arr(4)=10
arr(5)=1
arr(6)=6
'Finding the largest
largest=arr(0)
For i=1 to ubound(arr)
If largest largest=arr(i)
End If
Next
msgbox largest

'Finding the smallest
smallest=arr(0)
For i=1 to ubound(arr)
If smallest>arr(i) Then
smallest=arr(i)
End If
Next
msgbox smallest

1 comment:

LearnSumthingNew2day said...

Thanks Buddy :) You r doing a great job for beginners like me. Really Appreciated. Keep it goin ::) U rox