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

Most Capable Data Type Function
Convert Values Class

Public Function MostCapableDataType( _
      ByVal vOne As Variant _
    , ByVal vTwo As Variant _
    ) As Integer

Returns the VarType of the most CAPABLE of the data types of the two arguments.
The most capable data type is the one which has the widest range of values and is capable of representing vOne.

Examples:
    MostCapableDataType(CInt(1), CLng(1)) = vbLong
    MostCapableDataType(CLng(1), CSng(1)) = vbSingle
    MostCapableDataType(CBool(1), CByte(1)) = vbInteger
See also:
    MostAccurateDataType Function
    PromoteToMostCapableDataType Function
    CoerceToType Function
Summary: If one argument is Null, then the type of the other argument is the "most capable" If one argument is Empty, then the type of the other argument is the "most capable" If one argument is String, then String is the "most capable" Otherwise, the table below describes the result.
vOne: First of two values from which the identifier of most capable data type will be returned.
vTwo: Second of two values from which the most capable data type will be determined.
                        vOne
            Boo Byt Int Lng Sng Dbl Cur Dec Dat
          +------------------------------------
    v Boo | Boo Int Int Lng Sng Dbl Cur Dec Dbl
    v Byt | Int Byt Int Lng Sng Dbl Cur Dec Dbl
    a Int | Int Int Int Lng Sng Dbl Cur Dec Dbl
    r Lng | Lng Lng Lng Lng Dbl Dbl Cur Dec Dbl
    T Sng | Sng Sng Sng Dbl Sng Dbl Dbl Dbl Dbl
    w Dbl | Dbl Dbl Dbl Dbl Dbl Dbl Dbl Dbl Dbl
    o Cur | Cur Cur Cur Cur Dbl Dbl Cur Dec Dbl
      Dec | Dec Dec Dec Dec Dbl Dbl Dec Dec Dbl
      Dat | Dbl Dbl Dbl Dbl Dbl Dbl Dbl Dbl Dat
Legend:
    Boo = Boolean
    Byt = Byte
    Cur = Currency
    Dat = Date
    Dec = Decimal
    Dbl = Double (precision floating-point)
    Int = Integer
    Lng = Long (integer)
    Sng = Single (precision floating-point)
v1.5 Change: This function has been extended to support the new Decimal data type in VB 6.0.
v1.5 BugFix: Corrected a bug in this function that would cause it to work incorrectly when vOne was Null and vTwo was a boolean.

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