Const n = 20
Dim a(1 To n) As Integer
Private Sub Command1_Click()
Dim i As Integer
Randomize
For i = 1 To n
a(i) = Int(Rnd * 1000) + 1
List1.AddItem Str(a(i))
Next i
End Sub
Private Sub Command2_Click()
Dim i As Integer, max As Integer
Dim min As Integer, sum As Single
max = a(1): min = a(1)
sum = 0
For i = 2 To n
If Then max = a(i)
If a(i) < min Then min = a(i)
sum = sum + a(i)
Next i
Text1.Text = Str(max)
Text2.Text = Str(min)
Text3.Text = Str(sum)
End Sub