Private Sub Command1_Click()
Dim n As Integer, i As Integer, x As Integer, sum As Integer, avg As Single
Dim max As Integer, min As Integer, maxi As Integer, mini As Integer
n = Val(Text1.Text)
x = Int(Rnd * 100) + 1
List1.AddItem Str(x)
max = x : min = x
maxi = 1: mini = 1
For i = 2 To n
x = Int(Rnd * 100) + 1
List1.AddItem Str(x)
If x > max Then max = x: maxi = i
If Then min = x: mini = i
sum = sum + x
Next i
List2.AddItem “最大数为:” + Str(max) + “,所在位置为:” + Str(maxi)
List2.AddItem “最小数为:” + Str(min) + “,所在位置为:” + Str(mini)
List2.AddItem “平均值为:” + Str(avg)
End Sub