Sub Fix Ups Class

FixUpVariantToRange

Fix up the argument rValue so that it is within the range from vMin to vMax. rValue will be left unchanged if it is within the range, it will be set to vMin if it is less than vMin, or it will be set to vMax if it is greater than vMax.

Signature (Visual Basic / VBA)

Public Sub FixUpVariantToRange( _
      ByRef rValue As Variant _
    , ByVal vMin As Variant _
    , ByVal VMAX As Variant _
    )

Code Examples

    Assuming
       Dim intNum As Integer
       intNum = 20
    for example
       FixUpVariantToRange intNum, 30, 40
    leaves
       intNum = 30
    Assuming
       Dim strName As String
       strName = "Word"
    for example
       FixUpVariantToRange strName, "Alpha", "India"
    leaves
       strName = "India"
    Value < Min: Let Value = Min
    Value > Max: Let Value = Max
    Min <= Value <= Max: Do nothing.

Parameters

Parameter Description
rValue The value which is modified if it is not between vMin and vMax inclusive. This argument is set to vMin if less than vMin or vMax if greater than vMax.
vMin The lower-bound of the range of acceptable values. rValue will be set to vMin if it is less than vMin.
vMax The upper-bound of the range of acceptable values. rValue will be set to vMax if it is greater than vMax.

Notes & Version History

Note rValue is a pass-by-reference argument, so the value of the variable passed via this argument may be modified within the calling function.
Note This function performs Binary comparisons when the arguments are strings.