代码如下:
Option Base 1
Private Sub Form_Click()
Dim a, nMax%, pos%, i%, stg As String
a = Array(10, 68, 45, 100, 1, 2, 88, 3)
nMax = a(1)
For i = 1 To 8
strg = strg & a(i) & " "
If a(i) > nMax Then
nMax = a(i)
pos = i
End If
Next i
Print strg
Print
Print "最大值=" & nMax & " 位置是:" & pos
End Sub
运行效果