Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Return the lowest of five values 1

Status
Not open for further replies.

Syerston

Programmer
Jun 2, 2001
142
GB
Is there a way to take five currency figures from five text boxes and return the lowest of the five values. John
 
Code:
Public Function basMinVal(ParamArray varMyVals() As Variant) As Variant

    'Michael Red 10/25/2001
    'To return the MINIMUM or a series of values

    'Sample Usage:
    '? basMinVal(1, 5, 9, 3, 13.663)
    '1

    '?basMinVal(9, 1, 5, 3, 13.663)
    '1


    Dim Idx As Integer
    Dim MyMin As Variant

    If (UBound(varMyVals) < 0) Then
        Exit Function
     Else
        MyMin = varMyVals(0)
    End If

    For Idx = 0 To UBound(varMyVals())
        If (varMyVals(Idx) < MyMin) Then
            MyMin = varMyVals(Idx)
        End If
    Next Idx

    basMinVal = MyMin

End Function

MichaelRed
m.red@att.net

There is never time to do it right but there is always time to do it over
 
Michael
Brilliant!!!
Well worth two stars
Many Thanks John
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top