Len
- Last UpdatedJul 18, 2023
- 1 minute read
The Len function determines the number of characters in the Str argument. The LenB function determines the number of bytes in the VarName argument.
-
The Str argument can be any valid string expression. If Str contains Null, Null is returned.
-
The VarName argument can be any valid variable name. If VarName contains Null, Null is returned. If VarName is a Variant, LenB treats it the same as a String and returns the number of characters it contains.
Syntax
Len(Str)
Str:
A string or expression that can represent a valid text value.
Return Value
Returns a Long.
Related Functions
InStr | Left, Left$| Mid| Right
Example
Dim strTest as String
Dim lngStringLength as Long
strTest = "VBA"
lngStringLength = Len(strTest) ' returns 3