How to return the smallest parameter value.
Posted on January 4, 2009
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | 'Math - How to return the smallest parameter value. Option Explicit Private Function Min(ParamArray values() As Variant) As Variant Dim i As Integer Dim min_value As Variant min_value = values(LBound(values)) For i = LBound(values) + 1 To UBound(values) If min_value > values(i) Then min_value = values(i) Next i Min = min_value End Function 'Call this function as: ' txtMin.Text = Format$(Min(CInt(txtValue1.Text), CInt(txtValue2.Text), CInt(txtValue3.Text), _ ' CInt(txtValue4.Text), CInt(txtValue5.Text), CInt(txtValue6.Text), CInt(txtValue7.Text), _ ' CInt(txtValue8.Text))) |
Related posts:
- How to return the biggest parameter value.
- How to Use ADO’s GetRows method to quickly load data into an array
- How to generate a random number, in between two given values.
- How to Convert text into the Currency data type
- How to sum all the elements in an array
- How to Return the number of records in the table.
- How to Read Line By Line & Retrieve Each Word From Text File
- How to Return a specific line number from a file (note: first line = line number 0)
- How to Return Short path for given file (with long path)
- How to return Quotient and Remainder for given two numbers