Function Math Arithmetic Class

RangeComp

" Range Compare" or " Range Comparison" Determine is X is below, within, or above the range from A through B.

Signature (Visual Basic / VBA)

Public Function RangeComp( _
      ByVal vA As Variant _
    , ByVal vX As Variant _
    , ByVal vB As Variant _
    ) As Variant

Code Examples

    RangeComp(20, 10, 30) = -1
    RangeComp(20, 20, 30) = 0
    RangeComp(20, 25, 30) = 0
    RangeComp(20, 50, 30) = 1
    If X < A: Return -1.
    If A <= X <= B: Return 0.
    If X > B: Return 1.

Parameters

Parameter Description
vA The lower-bound of the range against which vX is compared. Function returns Null if vA is Null or cannot be fixed up to a number.
vX Number that is checked to see if it is below, within, or above the range from A through B inclusive. Function returns Null if vX is Null or cannot be fixed up to a number.
vB The upper-bound of the range against which vX is compared. Function returns Null if vA is Null or cannot be fixed up to a number.