转帖自wxy_xiaoyu(☆然也☆╭∩╮(︶︿︶)╭∩╮)的答案
http://expert.csdn.net/Expert/topic/1511/1511641.xml?temp=.9079553
Dim M(1 To 5) As DoublePrivate Sub Form_Load()
For i = 1 To 5
M(i) = i
Next
End Sub Public Function Max(ByRef SZtmp) As Double
Dim i%
Max = 0
For i = LBound(SZtmp) To UBound(SZtmp)
If CDbl(SZtmp(i)) > Max Then _
Max = CDbl(SZtmp(i))
Me.Print Max
Next i
End FunctionPrivate Sub Command1_Click()
Call Max(M)
End Sub
http://expert.csdn.net/Expert/topic/1511/1511641.xml?temp=.9079553
Dim M(1 To 5) As DoublePrivate Sub Form_Load()
For i = 1 To 5
M(i) = i
Next
End Sub Public Function Max(ByRef SZtmp) As Double
Dim i%
Max = 0
For i = LBound(SZtmp) To UBound(SZtmp)
If CDbl(SZtmp(i)) > Max Then _
Max = CDbl(SZtmp(i))
Me.Print Max
Next i
End FunctionPrivate Sub Command1_Click()
Call Max(M)
End Sub
MsgBox Max(1, 5, 2, 6, 8, 3)
End Sub
Function Max(ParamArray x()) As Double
Dim i As Integer
Max = 0
For i = LBound(x) To UBound(x)
Max = IIf(Max >= CDbl(x(i)), Max, CDbl(x(i)))
Next
End Function