Siebel VB Language Reference > VB Language Reference >

Len Function


This standard VB function returns the length of a string or string variable.

Syntax A

Len(string)

Syntax B

Len(varName)

Argument
Description

string

A string or an expression that evaluates to a string

varName

A variable that contains a string

Returns

The length of string or the string contained in the variable varName.

Usage

If the argument is a string, the number of characters in the string is returned. If the argument is a variant variable, Len returns the number of bytes required to represent its value as a string; otherwise, the length of the built-in data type or user-defined type is returned.

If syntax B is used, and varName is a variant containing a NULL, Len returns a Null variant.

Example

This example returns the length of a name entered by the user (including spaces).

Sub Button_Click
      Dim username as String
      username = "Chris Smith"
      count = Len(username)
End Sub

See Also

InStr Function

Siebel VB Language Reference