第二题:
Dim a(1 To 10) As Integer
Private Sub Command1_Click()
Max = a(1): Min = a(1): aver = 0
Sum = a(10)
For i = 1 To 9
Sum = Sum + a(i)
If a(i) < a(i + 1) Then Max = a(i + 1)
If a(i) > a(i + 1) Then Min = a(i + 1)
Next
aver = Sum / 10
p = "最大值为" & Max & "最小值为" & Min & "平均值" & aver
Label2.Caption = p
End Sub
Private Sub Form_Activate()
For i = 1 To 10
Randomize
a(i) = Int(Rnd * 90) + 10
s = s & Str(a(i)) & ","
Next
Label1.Caption = Left(s, Len(s) - 1)
End Sub
Private Sub Form_Load()
Form_Activate
End Sub