Private Sub Form_Activate()
Dim a(1 To 20) As Integer, b As Integer, c As Integer, d As Integer, e As Integer
Randomize
Print "随机数:";
For i = 1 To 20
a(i) = Int(Rnd * 50) + 50
If a(i) > d Then d = a(i)
e = e + a(i)
Print a(i);
Next
c = a(1)
For i = 2 To 20
If c > a(i) Then c = a(i)
Next
Print
Print "最小值为:"; c
Print "最大数为:"; d
Print "平均值为:"; e / i
End Sub
Option Base 1
Private Sub Command1_Click()
Dim arr(20) As Integer, max As Integer, min As Integer
Dim s As Single
Cls
max = 50
min = 100
Print "产生的随机数为:"
For i = LBound(arr) To UBound(arr)
Randomize
arr(i) = Int(Rnd * 51) + 50
If arr(i) > max Then max = arr(i)
If arr(i) < min Then min = arr(i)
s = s + arr(i)
Print arr(i);
If i Mod 10 = 0 Then Print
Next
Print "最大值为:"; max
Print "最小值为:"; min
Print "平均值为:"; s / 20
End Sub