Function Extremum(B As Boolean, ParamArray intVal() As Variant) As Single
'功能:求一组数字的最大(小)值
'参数:B=true 最大值,B=false 最小值
'示例:select Extremum(true,f1,f2,f3,f4,f5) as maxVal from tbname
Dim i As Long
Dim v As Single
If B = True Then
v = -1 * 10 ^ 10
Else
v = 10 ^ 10
End If
For i = 0 To UBound(intVal())
If B = True Then
If intVal(i) > v Then v = intVal(i)
Else
If intVal(i) < v Then v = intVal(i)
End If
Next i
Extremum = v
End Function
点击下载此附件