Function Convert Values Class

LengthOfType

Returns the length of the internal representation of any type of value. For Empty and Null variants, returns a length of zero. For other non-strings, the length is the number of bytes occupied by the variable.

Signature (Visual Basic / VBA)

Public Function LengthOfType( _
    ByVal vAny As Variant _
    ) As Long

Code Example

    LengthOfType(123) = 2
    LengthOfType(123@) = 8
    LengthOfType("12345") = 5
    LengthOfType(Null) = 0

Parameters

Parameter Description
vAny Function returns the length of the in-memory representation of the value. Function returns 0 (zero) if vAny is an Array, Empty, Error, Null, or Variant. Function returns Null if the data type is unrecognized.

Notes & Version History

Note If vAny is a string, this function returns the number of characters in the string (this is not necessarily the same as the length of the internal representation of the string on Unicode systems).
v1.5 Change This function has been extended to support the new Decimal data type in VB 6.0.