Function Comparisons Class

IsBetween

Return True if vCheck is between vLow and vHigh inclusive. Attempts to fix-up different types of values to compatible data types.

Signature (Visual Basic / VBA)

Public Function IsBetween( _
      ByVal vCheck As Variant _
    , ByVal vLow As Variant _
    , ByVal vHigh As Variant _
    , Optional ByVal vCompare As Variant _
    ) As Variant

Code Example

    IsBetween(5, 6.0, 7) = False
    IsBetween(5, 4.5, 7) = True
    IsBetween("S", "A", "Z", vbBinaryCompare) = True
    IsBetween("s", "A", "Z", vbBinaryCompare) = False
    IsBetween("s", "A", "Z", vbTextCompare) = True

Parameters

Parameter Description
vCheck The value which is checked to see if it falls within the inclusive range. Function returns Null if vCheck is Null.
vLow The lower bound of the range which vCheck must be within for the function to return True. Function returns Null if vLow is Null.
vHigh The upper bound of the range which vCheck must be within for the function to return True. Function returns Null if vHigh is Null.
vCompare Specifies the sort order/collating sequence used when comparing string values. vCompare defaults to Binary comparisons if it is missing or Null or cannot be fixed up to a number. If the arguments vCheck, vLow, and vHigh are non-Null, then this function uses the CompareLikeDataType function to determine if vCheck is within the range.