Function Comparisons Class

VarTypeToLength

Returns the number of bytes occupied by variables whose VarType is vVarType.

Signature (Visual Basic / VBA)

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

Code Example

    VarTypeToLength(VarType(34%)) = 2
    VarTypeToLength(VarType(34.5!)) = 4
    VarTypeToLength(VarType("A string.")) = 0 ' #3

Parameters

Parameter Description
vVarType The numeric constant which represents a specific Visual Basic data type.

Return Value

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. Function returns 0 (zero) if vVarType represents a variable-length data type or an array of some data type as in example #3.

Notes & Version History

v1.5 Change This function has been extended to support the new Decimal data type in VB 6.0.