VBS tutorial: Functions – len functions

Time:2021-10-22

Len function

Returns the number of characters in a string or the number of bytes required to store a variable.

Len(string | varname)

parameter

string

Any valid string expression. IfstringReturns if the parameter contains nullNull

Varname

Any valid variable name. Ifvarname Parameter containsNull, returnNull

explain

The following example usesLenFunction returns the number of characters in a string:

Dim mystringmystring = len ("VBScript")'mystring contains 8.

be careful LenBFunction is used with byte data contained in a string.LenBInstead of returning the number of characters in a string, it returns the number of bytes used to represent the string.