|
Post by u9 on Oct 19, 2006 7:43:02 GMT -5
How about a max() and a min() function, at least for floats and integers. I would free me up from having to do one very time i need it. These are pretty common functions.
|
|
|
Post by Guilect on Oct 19, 2006 8:28:24 GMT -5
I can add those.
For now here are min, max
Option Explicit
Function Min(avValues()) Dim vThisItem, vThisElement On Error Resume Next For Each vThisItem In avValues If IsArray(vThisItem) Then For Each vThisElement In vThisItem Min = Min(vThisElement, Min) Next Else If vThisItem < Min Then If Not IsEmpty(vThisItem) Then Min = vThisItem End If ElseIf IsEmpty(Min) Then Min = vThisItem End If End If Next On Error GoTo 0 End Function
'Purpose : Returns the Maximum value from a parameter Array 'Inputs : avValues() as Variant 'Outputs : The Max Value contained within the input (excluding empty values) 'Notes : Examples: ' Max(1,2,empty,-1) Returns 2 ' Max(Array(1,2,-1),-4,-9.9) Returns 2 ' Max(1/Jan/99,2/Jan/99) Returns 2/Jan/99 'Revisions :
Function Max(avValues()) Dim vThisItem, vThisElement On Error Resume Next For Each vThisItem In avValues If IsArray(vThisItem) Then For Each vThisElement In vThisItem Max = Max(vThisElement, Max) Next Else If vThisItem > Max Then If Not IsEmpty(vThisItem) Then Max = vThisItem End If ElseIf IsEmpty(Max) Then Max = vThisItem End If End If Next On Error GoTo 0 End Function
system.debugPrint min(Array(1,2,3)) system.debugPrint max(Array(1,2,3))
|
|