Option Explicit
Option Base 1
Private Sub Command1_Click()
Dim a(20) As Integer, i As Integer, st As String
Dim max As Integer, min As Integer, maxp As Integer, minp As Integer
For i = 1 To 20
a(i) = Int(100 * Rnd) + 1
st = st & Str(a(i))
If i Mod 10 = 0 Then st = st & vbCrLf
Next i
Text1 = st
max = a(1): min = a(1)
maxp = 1: minp = 1
For i = 2 To 20
If a(i) > max Then
max = a(i)
maxp = i
ElseIf a(i) < min Then
min = a(i)
minp = i
End If
Next i
Text2 = Val(max) & "位置是" & Val(maxp)
Text3 = Val(min) & "位置是" & Val(minp)
End Sub
Private Sub Command2_Click()
Text1 = "": Text2 = "": Text3 = ""
End Sub
Private Sub Command3_Click()
End
End Sub
温馨提示:答案为网友推荐,仅供参考