Len Function

Returns the number of characters in a character string.

Syntax
Len(string)

Parameters

string
Specify a string expression.

Return Values
Returns an integer number representing the number of characters in the string which was given as an argument to the Len instruction.

Description
Len returns an integer number representing the number of characters in a string specified by the user. (Len will return values between 0 and 255 (since a string can contain between 0 and 255 characters).

See Also
Asc, Chr$, InStr, Left$, Mid$, Right$, Space$, Str$, Val

Len Function Example
The example shown below shows a program which takes a part data string as its input and parses out the part number, part name, and part count.

Function ParsePartData(DataIn$ As String, ByRef PartNum$ As String, ByRef PartName$ As String, ByRef PartCount As Integer)

    Integer pos
    String temp$

    pos = Instr(DataIn$, ",")
    PartNum$ = Left$(DataIn$, pos - 1)

    DataIn$ = Right$(datain$, Len(DataIn$) - pos)
    pos = Instr(DataIn$, ",")

    PartName$ = Left$(DataIn$, pos - 1)

    PartCount = Val(Right$(datain$, Len(DataIn$) - pos))

Fend

Some other example results from the Len instruction from the command window.

> ? len("ABCDEFG")
7

> ? len("ABC")
3

> ? len("")
0
>