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

Compare Like Data Type Fast Function
Comparisons Class

Public Function CompareLikeDataTypeFast( _
      ByRef vOne As Variant _
    , ByRef vTwo As Variant _
    , ByRef vCompare As VbCompareMethod _
    ) 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.
Faster version of the CompareLikeDataType function which has more-restrictive argument types.

    CompareLikeDataTypeFast("ALL", "all", vbBinaryCompare) = -1
    CompareLikeDataTypeFast("all", "ALL", vbBinaryCompare) = 1
    CompareLikeDataTypeFast("ALL", "all", vbTextCompare) = 0
    CompareLikeDataTypeFast("3", 3, vbTextCompare) = 1
See also:
    CompareLikeDataType Function
    EqualLikeDataTypeFast 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.
Summary: 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 to be compared.
vTwo: Second of two values to be compared.
vCompare: Specifies the comparison type and sort order/collating sequence used when comparing string values.
Return value:
           D S
    vOne D n -
         S + s
VarType Codes:
    D = Date/Numeric
    S = String
Action Codes:
    - = 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.