Signature (Visual Basic / VBA)
Public Function MostCapableDataType( _
ByVal vOne As Variant _
, ByVal vTwo As Variant _
) As Integer
Code Examples
MostCapableDataType(CInt(1), CLng(1)) = vbLong
MostCapableDataType(CLng(1), CSng(1)) = vbSingle
MostCapableDataType(CBool(1), CByte(1)) = vbInteger
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
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)
Parameters
| Parameter | Description |
|---|---|
| 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. |
Notes & Version History
| 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. |
| 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. |