Len, LenB Functions
Data Type: String
A valid string literal or string expression.
Data Type: Any except Object
A valid variable name.
Len returns the number of characters in a string or variable. LenB returns the number of bytes required to store a string in memory.
varname are mutually exclusive; that
is, you must specify either
varname, but not both.
Null, Len and
You can’t use Len or LenB with an object variable.
varname is an array, you
must also specify a valid subscript. In other words,
can’t determine the total number of elements in or the total
size of an array. To determine the size of an array, use the
LBound and UBound
Nonstring data is treated the same as strings when passed to the Len and LenB functions. For example, in the code:
Dim number number = 100 WScript.Echo Len(number)
the Len function returns 3, since
that is the number of characters in the value of
LenB is intended to work with string data, and returns the number of bytes required to store that string. If a nonstring data type is passed to the LenB function, its value is first converted to a string before its length is determined.
Although the Len and LenB functions handle strings identically in VBA and VBScript, they handle non-string ...