Private Sub ProcMin(a() As Integer, ByVal amin As Integer)
Dim i%, amin0%
For i = LBound(a) To UBound(a)
Print a(i);
amin0 = a(LBound(a))
If a(i) < amin0 Then amin = a(i)
Next i
Print
Print "amin="; amin
End Sub
Private Sub Command1_Click()
Dim a(1 To 10) As Integer, i% ', amin0%
For i = 1 To 10
a(i) = Int(501 * Rnd + 300)
Next i
Call ProcMin(a(), amin)
End Sub
主程序
Dim a(10) As Integer
Randomize
For i = 0 To 9
a(i) = Int((800 - 300 + 1) * Rnd + 300)
Next
ProcMin(a())
--子函数
Function ProcMin(a() As Integer) As Integer
Dim min As Integer
min = a(0)
For i = 1 To 9
If min > a(i) Then
min = a(i)
End If
Next
ProcMin = min
End Function
他们编的都很好!