Function Math Arithmetic Class

NumComp

"Number Compare" or "Numeric Comparison" Determine if one number is less than, equal to, or greater than the other. Returns -1 if A < B; 0 if A = B; 1 if A > B.

Signature (Visual Basic / VBA)

Public Function NumComp( _
      ByVal vA As Variant _
    , ByVal vB As Variant _
    ) As Variant

Code Examples

    NumComp(3, 4) = -1
    NumComp(4, 4) = 0
    NumComp(5, 4) = 1
    A < B: Return -1.
    A = B: Return 0.
    A > B: Return 1.
    Sgn(A - B)

Parameters

Parameter Description
vA First of the two numbers that are compared to see if it is less than, equal to, or greater than the other. Function returns Null if vA is Null or cannot be fixed up to a number.
vB Second of the two numbers that are compared to see if it is less than, equal to, or greater than the other. Function returns Null if vA is Null or cannot be fixed up to a number.