Function Comparisons Class

VarTypeToString

"Variable Type To String" Converts a numeric value returned by the Visual Basic VarType function into a string which names the data type.

Signature (Visual Basic / VBA)

Public Function VarTypeToString( _
    ByVal vVarType As Variant _
    ) As Variant

Code Example

    VarTypeToString(VarType("A string here.")) = "String"
    VarTypeToString(VarType(34.5!) = "Single"
    VarTypeToString(VarType(Null) = "Null"
    VarTypeToString(vbString) = "String"

Parameters

Parameter Description
vVarType The numeric constant which represents a specific Visual Basic data type. Function returns Null if vVarType is Null or cannot be fixed up to a number. Function returns Null if vVarType does not represent the VarType value of a Visual Basic data type.

Notes & Version History

v1.2 BugFix Changed function to correctly recognize arrays of types other than Variant. Arrays are now identified by names like "Currency Array" or "Variant Array".
v1.5 Change This function has been extended to support the new Decimal data type in VB 6.0.