Monday 7 July 2014

Largest and smallest from an array




Code:
Dim a(10) As Integer, i As Integer, value As Integer, large As Integer, small As Integer

Private Sub Command1_Click()
For i = 0 To 10
value = InputBox("Enter a number", "input")
a(i) = value
List1.AddItem (value)
Next i
End Sub

Private Sub Command2_Click()
large = a(0)
For i = 1 To 10
If large < a(i) Then
large = a(i)
End If
Next i
Text1.Text = large
End Sub

Private Sub Command3_Click()
small = a(0)
For i = 1 To 10
If small > a(i) Then
small = a(i)
End If
Next i
Text2.Text = small
End Sub

Private Sub Command4_Click()
List1.Clear
Text1.Text = Clear
Text2.Text = Clear
End Sub

No comments:

Post a Comment