<-- Previous || Up || Next -->

Compare Like Data Type Function
Comparisons Class

Public Function CompareLikeDataType( _
      ByVal vOne As Variant _
    , ByVal vTwo As Variant _
    , Optional ByVal vCompare As Variant _
    ) As Integer

Compare two values to determine if one is less than, equal to, or greater than the other.
Compares values with similar data types, but never considers strings equal to numbers.

Examples:
    CompareLikeDataType("ALL", "all", vbBinaryCompare) = -1
    CompareLikeDataType("all", "ALL", vbBinaryCompare) = 1
    CompareLikeDataType("ALL", "all", vbTextCompare) = 0
    CompareLikeDataType("3", 3) = 1
    CompareLikeDataType(Null, 3) = -1
See also:
    CompareLikeDataTypeFast Function
    CompareCoerceDataType Function
    CompareExactDataType Function
    EqualLikeDataType Function
    StrComp Function (Visual Basic)
Function returns:
    -1 if vOne < vTwo
     0 if vOne = vTwo
     1 if vOne > vTwo
See the following table which describes how comparisons are made depending upon data type of arguments.
Similar to the CompareCoerceDataType function, except that one fixes-up numeric values to strings if the other argument is a string.
Summary: Empty is less than Null is less than Number is less than String. With Number/Date and Number/Date, use numeric comparison. With Number/Date and String, COMPARE THE VARTYPE. With String and String, use string comparison.
vOne: First of two values which are to be compared to determine if it is less than, equal to, or greater than the other.
vTwo: Second of two values which are to be compared to determine if it is less than, equal to, or greater than the other.
vCompare: Specifies the comparison type and 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.
Return value:
             vTwo
           E N D S
    vOne E 0 - - -
         N + 0 - -
         D + + n -
         S + + + s
VarType Codes:
    E = Empty
    N = Null
    D = Date/Numeric
    S = String
Action Codes:
    0 = Return 0
    - = Return -1
    + = Return 1
    s = Do String comparison with StrComp
    n = Do numeric/Date comparison

Copyright 1996-1999 Entisoft
Entisoft Tools is a trademark of Entisoft.