Strings.Len Strings.Len Strings.Len Strings.Len Method

Definition

Returns an integer containing either the number of characters in a string or the nominal number of bytes required to store a variable.

Overloads

Len(UInt64) Len(UInt64) Len(UInt64) Len(UInt64)

Returns an integer containing either the number of characters in a string or the nominal number of bytes required to store a variable.

Len(UInt32) Len(UInt32) Len(UInt32) Len(UInt32)

Returns an integer containing either the number of characters in a string or the nominal number of bytes required to store a variable.

Len(UInt16) Len(UInt16) Len(UInt16) Len(UInt16)

Returns an integer containing either the number of characters in a string or the nominal number of bytes required to store a variable.

Len(String) Len(String) Len(String) Len(String)

Returns an integer containing either the number of characters in a string or the nominal number of bytes required to store a variable.

Len(Single) Len(Single) Len(Single) Len(Single)

Returns an integer containing either the number of characters in a string or the nominal number of bytes required to store a variable.

Len(SByte) Len(SByte) Len(SByte) Len(SByte)

Returns an integer containing either the number of characters in a string or the nominal number of bytes required to store a variable.

Len(Object) Len(Object) Len(Object) Len(Object)

Returns an integer containing either the number of characters in a string or the nominal number of bytes required to store a variable.

Len(Int64) Len(Int64) Len(Int64) Len(Int64)

Returns an integer containing either the number of characters in a string or the nominal number of bytes required to store a variable.

Len(Int16) Len(Int16) Len(Int16) Len(Int16)

Returns an integer containing either the number of characters in a string or the nominal number of bytes required to store a variable.

Len(Double) Len(Double) Len(Double) Len(Double)

Returns an integer containing either the number of characters in a string or the nominal number of bytes required to store a variable.

Len(Decimal) Len(Decimal) Len(Decimal) Len(Decimal)

Returns an integer containing either the number of characters in a string or the nominal number of bytes required to store a variable.

Len(DateTime) Len(DateTime) Len(DateTime) Len(DateTime)

Returns an integer containing either the number of characters in a string or the nominal number of bytes required to store a variable.

Len(Char) Len(Char) Len(Char) Len(Char)

Returns an integer containing either the number of characters in a string or the nominal number of bytes required to store a variable.

Len(Byte) Len(Byte) Len(Byte) Len(Byte)

Returns an integer containing either the number of characters in a string or the nominal number of bytes required to store a variable.

Len(Boolean) Len(Boolean) Len(Boolean) Len(Boolean)

Returns an integer containing either the number of characters in a string or the nominal number of bytes required to store a variable.

Len(Int32) Len(Int32) Len(Int32) Len(Int32)

Returns an integer containing either the number of characters in a string or the nominal number of bytes required to store a variable.

Len(UInt64) Len(UInt64) Len(UInt64) Len(UInt64)

Important

This API is not CLS-compliant.

CLS-compliant alternative
Microsoft.VisualBasic.Strings.Len(Int64)

Returns an integer containing either the number of characters in a string or the nominal number of bytes required to store a variable.

public:
 static int Len(System::UInt64 Expression);
[System.CLSCompliant(false)]
public static int Len (ulong Expression);
static member Len : uint64 -> int
Public Function Len (Expression As ULong) As Integer

Parameters

Expression
UInt64 UInt64 UInt64 UInt64

Any valid String expression or variable name. If Expression is of type Object, the Len function returns the size as it will be written to the file by the FilePut function.

Returns

An integer containing either the number of characters in a string or the nominal number of bytes required to store a variable.

Examples

This example uses Len to return the number of characters in a string.

' Initializes variable.
Dim testString As String = "Hello World"
' Returns 11.
Dim testLen As Integer = Len(testString)

Remarks

With user-defined types and Object variables, the Len function returns the size as it will be written to the file by the FilePut function. If an Object contains a String, it will return the length of the string. If an Object contains any other type, it will return the size of the object as it will be written to the file by the FilePut function.

The VBFixedString attribute can be applied to string fields in objects to indicate the size of the string, in bytes, when written to disk. The Len function uses the VBFixedString attribute, if available, when determining the size of Object variables.

Note

The Len function may not be able to determine the actual number of storage bytes required when used with variable-length strings in user-defined data types.

Note

The LenB function in earlier versions of Visual Basic returns the number of bytes in a string rather than characters. It is used primarily for converting strings in double-byte character set (DBCS) applications. All current Visual Basic strings are in Unicode, and LenB is no longer supported.

Smart Device Developer Notes

The Len function accepts only String and Object variables as parameters. If an Object contains a String, it will return the length of the String. If a parameter is a NULL Object reference, the function returns zero. If an Object contains any other type, an exception is thrown.

See also

Len(UInt32) Len(UInt32) Len(UInt32) Len(UInt32)

Important

This API is not CLS-compliant.

CLS-compliant alternative
Microsoft.VisualBasic.Strings.Len(Int32)

Returns an integer containing either the number of characters in a string or the nominal number of bytes required to store a variable.

public:
 static int Len(System::UInt32 Expression);
[System.CLSCompliant(false)]
public static int Len (uint Expression);
static member Len : uint32 -> int
Public Function Len (Expression As UInteger) As Integer

Parameters

Expression
UInt32 UInt32 UInt32 UInt32

Any valid String expression or variable name. If Expression is of type Object, the Len function returns the size as it will be written to the file by the FilePut function.

Returns

An integer containing either the number of characters in a string or the nominal number of bytes required to store a variable.

Examples

This example uses Len to return the number of characters in a string.

' Initializes variable.
Dim testString As String = "Hello World"
' Returns 11.
Dim testLen As Integer = Len(testString)

Remarks

With user-defined types and Object variables, the Len function returns the size as it will be written to the file by the FilePut function. If an Object contains a String, it will return the length of the string. If an Object contains any other type, it will return the size of the object as it will be written to the file by the FilePut function.

The VBFixedString attribute can be applied to string fields in objects to indicate the size of the string, in bytes, when written to disk. The Len function uses the VBFixedString attribute, if available, when determining the size of Object variables.

Note

The Len function may not be able to determine the actual number of storage bytes required when used with variable-length strings in user-defined data types.

Note

The LenB function in earlier versions of Visual Basic returns the number of bytes in a string rather than characters. It is used primarily for converting strings in double-byte character set (DBCS) applications. All current Visual Basic strings are in Unicode, and LenB is no longer supported.

Smart Device Developer Notes

The Len function accepts only String and Object variables as parameters. If an Object contains a String, it will return the length of the String. If a parameter is a NULL Object reference, the function returns zero. If an Object contains any other type, an exception is thrown.

See also

Len(UInt16) Len(UInt16) Len(UInt16) Len(UInt16)

Important

This API is not CLS-compliant.

CLS-compliant alternative
Microsoft.VisualBasic.Strings.Len(Int16)

Returns an integer containing either the number of characters in a string or the nominal number of bytes required to store a variable.

public:
 static int Len(System::UInt16 Expression);
[System.CLSCompliant(false)]
public static int Len (ushort Expression);
static member Len : uint16 -> int
Public Function Len (Expression As UShort) As Integer

Parameters

Expression
UInt16 UInt16 UInt16 UInt16

Any valid String expression or variable name. If Expression is of type Object, the Len function returns the size as it will be written to the file by the FilePut function.

Returns

An integer containing either the number of characters in a string or the nominal number of bytes required to store a variable.

Examples

This example uses Len to return the number of characters in a string.

' Initializes variable.
Dim testString As String = "Hello World"
' Returns 11.
Dim testLen As Integer = Len(testString)

Remarks

With user-defined types and Object variables, the Len function returns the size as it will be written to the file by the FilePut function. If an Object contains a String, it will return the length of the string. If an Object contains any other type, it will return the size of the object as it will be written to the file by the FilePut function.

The VBFixedString attribute can be applied to string fields in objects to indicate the size of the string, in bytes, when written to disk. The Len function uses the VBFixedString attribute, if available, when determining the size of Object variables.

Note

The Len function may not be able to determine the actual number of storage bytes required when used with variable-length strings in user-defined data types.

Note

The LenB function in earlier versions of Visual Basic returns the number of bytes in a string rather than characters. It is used primarily for converting strings in double-byte character set (DBCS) applications. All current Visual Basic strings are in Unicode, and LenB is no longer supported.

Smart Device Developer Notes

The Len function accepts only String and Object variables as parameters. If an Object contains a String, it will return the length of the String. If a parameter is a NULL Object reference, the function returns zero. If an Object contains any other type, an exception is thrown.

See also

Len(String) Len(String) Len(String) Len(String)

Returns an integer containing either the number of characters in a string or the nominal number of bytes required to store a variable.

public:
 static int Len(System::String ^ Expression);
public static int Len (string Expression);
static member Len : string -> int
Public Function Len (Expression As String) As Integer

Parameters

Expression
String String String String

Any valid String expression or variable name. If Expression is of type Object, the Len function returns the size as it will be written to the file by the FilePut function.

Returns

An integer containing either the number of characters in a string or the nominal number of bytes required to store a variable.

Examples

This example uses Len to return the number of characters in a string.

' Initializes variable.
Dim testString As String = "Hello World"
' Returns 11.
Dim testLen As Integer = Len(testString)

Remarks

With user-defined types and Object variables, the Len function returns the size as it will be written to the file by the FilePut function. If an Object contains a String, it will return the length of the string. If an Object contains any other type, it will return the size of the object as it will be written to the file by the FilePut function.

The VBFixedString attribute can be applied to string fields in objects to indicate the size of the string, in bytes, when written to disk. The Len function uses the VBFixedString attribute, if available, when determining the size of Object variables.

Note

The Len function may not be able to determine the actual number of storage bytes required when used with variable-length strings in user-defined data types.

Note

The LenB function in earlier versions of Visual Basic returns the number of bytes in a string rather than characters. It is used primarily for converting strings in double-byte character set (DBCS) applications. All current Visual Basic strings are in Unicode, and LenB is no longer supported.

Smart Device Developer Notes

The Len function accepts only String and Object variables as parameters. If an Object contains a String, it will return the length of the String. If a parameter is a NULL Object reference, the function returns zero. If an Object contains any other type, an exception is thrown.

See also

Len(Single) Len(Single) Len(Single) Len(Single)

Returns an integer containing either the number of characters in a string or the nominal number of bytes required to store a variable.

public:
 static int Len(float Expression);
public static int Len (float Expression);
static member Len : single -> int
Public Function Len (Expression As Single) As Integer

Parameters

Expression
Single Single Single Single

Any valid String expression or variable name. If Expression is of type Object, the Len function returns the size as it will be written to the file by the FilePut function.

Returns

An integer containing either the number of characters in a string or the nominal number of bytes required to store a variable.

Examples

This example uses Len to return the number of characters in a string.

' Initializes variable.
Dim testString As String = "Hello World"
' Returns 11.
Dim testLen As Integer = Len(testString)

Remarks

With user-defined types and Object variables, the Len function returns the size as it will be written to the file by the FilePut function. If an Object contains a String, it will return the length of the string. If an Object contains any other type, it will return the size of the object as it will be written to the file by the FilePut function.

The VBFixedString attribute can be applied to string fields in objects to indicate the size of the string, in bytes, when written to disk. The Len function uses the VBFixedString attribute, if available, when determining the size of Object variables.

Note

The Len function may not be able to determine the actual number of storage bytes required when used with variable-length strings in user-defined data types.

Note

The LenB function in earlier versions of Visual Basic returns the number of bytes in a string rather than characters. It is used primarily for converting strings in double-byte character set (DBCS) applications. All current Visual Basic strings are in Unicode, and LenB is no longer supported.

Smart Device Developer Notes

The Len function accepts only String and Object variables as parameters. If an Object contains a String, it will return the length of the String. If a parameter is a NULL Object reference, the function returns zero. If an Object contains any other type, an exception is thrown.

See also

Len(SByte) Len(SByte) Len(SByte) Len(SByte)

Important

This API is not CLS-compliant.

CLS-compliant alternative
Microsoft.VisualBasic.Strings.Len(Byte)

Returns an integer containing either the number of characters in a string or the nominal number of bytes required to store a variable.

public:
 static int Len(System::SByte Expression);
[System.CLSCompliant(false)]
public static int Len (sbyte Expression);
static member Len : sbyte -> int
Public Function Len (Expression As SByte) As Integer

Parameters

Expression
SByte SByte SByte SByte

Any valid String expression or variable name. If Expression is of type Object, the Len function returns the size as it will be written to the file by the FilePut function.

Returns

An integer containing either the number of characters in a string or the nominal number of bytes required to store a variable.

Examples

This example uses Len to return the number of characters in a string.

' Initializes variable.
Dim testString As String = "Hello World"
' Returns 11.
Dim testLen As Integer = Len(testString)

Remarks

With user-defined types and Object variables, the Len function returns the size as it will be written to the file by the FilePut function. If an Object contains a String, it will return the length of the string. If an Object contains any other type, it will return the size of the object as it will be written to the file by the FilePut function.

The VBFixedString attribute can be applied to string fields in objects to indicate the size of the string, in bytes, when written to disk. The Len function uses the VBFixedString attribute, if available, when determining the size of Object variables.

Note

The Len function may not be able to determine the actual number of storage bytes required when used with variable-length strings in user-defined data types.

Note

The LenB function in earlier versions of Visual Basic returns the number of bytes in a string rather than characters. It is used primarily for converting strings in double-byte character set (DBCS) applications. All current Visual Basic strings are in Unicode, and LenB is no longer supported.

Smart Device Developer Notes

The Len function accepts only String and Object variables as parameters. If an Object contains a String, it will return the length of the String. If a parameter is a NULL Object reference, the function returns zero. If an Object contains any other type, an exception is thrown.

See also

Len(Object) Len(Object) Len(Object) Len(Object)

Returns an integer containing either the number of characters in a string or the nominal number of bytes required to store a variable.

public:
 static int Len(System::Object ^ Expression);
public static int Len (object Expression);
static member Len : obj -> int
Public Function Len (Expression As Object) As Integer

Parameters

Expression
Object Object Object Object

Any valid String expression or variable name. If Expression is of type Object, the Len function returns the size as it will be written to the file by the FilePut function.

Returns

An integer containing either the number of characters in a string or the nominal number of bytes required to store a variable.

Examples

This example uses Len to return the number of characters in a string.

' Initializes variable.
Dim testString As String = "Hello World"
' Returns 11.
Dim testLen As Integer = Len(testString)

Remarks

With user-defined types and Object variables, the Len function returns the size as it will be written to the file by the FilePut function. If an Object contains a String, it will return the length of the string. If an Object contains any other type, it will return the size of the object as it will be written to the file by the FilePut function.

The VBFixedString attribute can be applied to string fields in objects to indicate the size of the string, in bytes, when written to disk. The Len function uses the VBFixedString attribute, if available, when determining the size of Object variables.

Note

The Len function may not be able to determine the actual number of storage bytes required when used with variable-length strings in user-defined data types.

Note

The LenB function in earlier versions of Visual Basic returns the number of bytes in a string rather than characters. It is used primarily for converting strings in double-byte character set (DBCS) applications. All current Visual Basic strings are in Unicode, and LenB is no longer supported.

Smart Device Developer Notes

The Len function accepts only String and Object variables as parameters. If an Object contains a String, it will return the length of the String. If a parameter is a NULL Object reference, the function returns zero. If an Object contains any other type, an exception is thrown.

See also

Len(Int64) Len(Int64) Len(Int64) Len(Int64)

Returns an integer containing either the number of characters in a string or the nominal number of bytes required to store a variable.

public:
 static int Len(long Expression);
public static int Len (long Expression);
static member Len : int64 -> int
Public Function Len (Expression As Long) As Integer

Parameters

Expression
Int64 Int64 Int64 Int64

Any valid String expression or variable name. If Expression is of type Object, the Len function returns the size as it will be written to the file by the FilePut function.

Returns

An integer containing either the number of characters in a string or the nominal number of bytes required to store a variable.

Examples

This example uses Len to return the number of characters in a string.

' Initializes variable.
Dim testString As String = "Hello World"
' Returns 11.
Dim testLen As Integer = Len(testString)

Remarks

With user-defined types and Object variables, the Len function returns the size as it will be written to the file by the FilePut function. If an Object contains a String, it will return the length of the string. If an Object contains any other type, it will return the size of the object as it will be written to the file by the FilePut function.

The VBFixedString attribute can be applied to string fields in objects to indicate the size of the string, in bytes, when written to disk. The Len function uses the VBFixedString attribute, if available, when determining the size of Object variables.

Note

The Len function may not be able to determine the actual number of storage bytes required when used with variable-length strings in user-defined data types.

Note

The LenB function in earlier versions of Visual Basic returns the number of bytes in a string rather than characters. It is used primarily for converting strings in double-byte character set (DBCS) applications. All current Visual Basic strings are in Unicode, and LenB is no longer supported.

Smart Device Developer Notes

The Len function accepts only String and Object variables as parameters. If an Object contains a String, it will return the length of the String. If a parameter is a NULL Object reference, the function returns zero. If an Object contains any other type, an exception is thrown.

See also

Len(Int16) Len(Int16) Len(Int16) Len(Int16)

Returns an integer containing either the number of characters in a string or the nominal number of bytes required to store a variable.

public:
 static int Len(short Expression);
public static int Len (short Expression);
static member Len : int16 -> int
Public Function Len (Expression As Short) As Integer

Parameters

Expression
Int16 Int16 Int16 Int16

Any valid String expression or variable name. If Expression is of type Object, the Len function returns the size as it will be written to the file by the FilePut function.

Returns

An integer containing either the number of characters in a string or the nominal number of bytes required to store a variable.

Examples

This example uses Len to return the number of characters in a string.

' Initializes variable.
Dim testString As String = "Hello World"
' Returns 11.
Dim testLen As Integer = Len(testString)

Remarks

With user-defined types and Object variables, the Len function returns the size as it will be written to the file by the FilePut function. If an Object contains a String, it will return the length of the string. If an Object contains any other type, it will return the size of the object as it will be written to the file by the FilePut function.

The VBFixedString attribute can be applied to string fields in objects to indicate the size of the string, in bytes, when written to disk. The Len function uses the VBFixedString attribute, if available, when determining the size of Object variables.

Note

The Len function may not be able to determine the actual number of storage bytes required when used with variable-length strings in user-defined data types.

Note

The LenB function in earlier versions of Visual Basic returns the number of bytes in a string rather than characters. It is used primarily for converting strings in double-byte character set (DBCS) applications. All current Visual Basic strings are in Unicode, and LenB is no longer supported.

Smart Device Developer Notes

The Len function accepts only String and Object variables as parameters. If an Object contains a String, it will return the length of the String. If a parameter is a NULL Object reference, the function returns zero. If an Object contains any other type, an exception is thrown.

See also

Len(Double) Len(Double) Len(Double) Len(Double)

Returns an integer containing either the number of characters in a string or the nominal number of bytes required to store a variable.

public:
 static int Len(double Expression);
public static int Len (double Expression);
static member Len : double -> int
Public Function Len (Expression As Double) As Integer

Parameters

Expression
Double Double Double Double

Any valid String expression or variable name. If Expression is of type Object, the Len function returns the size as it will be written to the file by the FilePut function.

Returns

An integer containing either the number of characters in a string or the nominal number of bytes required to store a variable.

Examples

This example uses Len to return the number of characters in a string.

' Initializes variable.
Dim testString As String = "Hello World"
' Returns 11.
Dim testLen As Integer = Len(testString)

Remarks

With user-defined types and Object variables, the Len function returns the size as it will be written to the file by the FilePut function. If an Object contains a String, it will return the length of the string. If an Object contains any other type, it will return the size of the object as it will be written to the file by the FilePut function.

The VBFixedString attribute can be applied to string fields in objects to indicate the size of the string, in bytes, when written to disk. The Len function uses the VBFixedString attribute, if available, when determining the size of Object variables.

Note

The Len function may not be able to determine the actual number of storage bytes required when used with variable-length strings in user-defined data types.

Note

The LenB function in earlier versions of Visual Basic returns the number of bytes in a string rather than characters. It is used primarily for converting strings in double-byte character set (DBCS) applications. All current Visual Basic strings are in Unicode, and LenB is no longer supported.

Smart Device Developer Notes

The Len function accepts only String and Object variables as parameters. If an Object contains a String, it will return the length of the String. If a parameter is a NULL Object reference, the function returns zero. If an Object contains any other type, an exception is thrown.

See also

Len(Decimal) Len(Decimal) Len(Decimal) Len(Decimal)

Returns an integer containing either the number of characters in a string or the nominal number of bytes required to store a variable.

public:
 static int Len(System::Decimal Expression);
public static int Len (decimal Expression);
static member Len : decimal -> int
Public Function Len (Expression As Decimal) As Integer

Parameters

Expression
Decimal Decimal Decimal Decimal

Any valid String expression or variable name. If Expression is of type Object, the Len function returns the size as it will be written to the file by the FilePut function.

Returns

An integer containing either the number of characters in a string or the nominal number of bytes required to store a variable.

Examples

This example uses Len to return the number of characters in a string.

' Initializes variable.
Dim testString As String = "Hello World"
' Returns 11.
Dim testLen As Integer = Len(testString)

Remarks

With user-defined types and Object variables, the Len function returns the size as it will be written to the file by the FilePut function. If an Object contains a String, it will return the length of the string. If an Object contains any other type, it will return the size of the object as it will be written to the file by the FilePut function.

The VBFixedString attribute can be applied to string fields in objects to indicate the size of the string, in bytes, when written to disk. The Len function uses the VBFixedString attribute, if available, when determining the size of Object variables.

Note

The Len function may not be able to determine the actual number of storage bytes required when used with variable-length strings in user-defined data types.

Note

The LenB function in earlier versions of Visual Basic returns the number of bytes in a string rather than characters. It is used primarily for converting strings in double-byte character set (DBCS) applications. All current Visual Basic strings are in Unicode, and LenB is no longer supported.

Smart Device Developer Notes

The Len function accepts only String and Object variables as parameters. If an Object contains a String, it will return the length of the String. If a parameter is a NULL Object reference, the function returns zero. If an Object contains any other type, an exception is thrown.

See also

Len(DateTime) Len(DateTime) Len(DateTime) Len(DateTime)

Returns an integer containing either the number of characters in a string or the nominal number of bytes required to store a variable.

public:
 static int Len(DateTime Expression);
public static int Len (DateTime Expression);
static member Len : DateTime -> int
Public Function Len (Expression As DateTime) As Integer

Parameters

Expression
DateTime DateTime DateTime DateTime

Any valid String expression or variable name. If Expression is of type Object, the Len function returns the size as it will be written to the file by the FilePut function.

Returns

An integer containing either the number of characters in a string or the nominal number of bytes required to store a variable.

Examples

This example uses Len to return the number of characters in a string.

' Initializes variable.
Dim testString As String = "Hello World"
' Returns 11.
Dim testLen As Integer = Len(testString)

Remarks

With user-defined types and Object variables, the Len function returns the size as it will be written to the file by the FilePut function. If an Object contains a String, it will return the length of the string. If an Object contains any other type, it will return the size of the object as it will be written to the file by the FilePut function.

The VBFixedString attribute can be applied to string fields in objects to indicate the size of the string, in bytes, when written to disk. The Len function uses the VBFixedString attribute, if available, when determining the size of Object variables.

Note

The Len function may not be able to determine the actual number of storage bytes required when used with variable-length strings in user-defined data types.

Note

The LenB function in earlier versions of Visual Basic returns the number of bytes in a string rather than characters. It is used primarily for converting strings in double-byte character set (DBCS) applications. All current Visual Basic strings are in Unicode, and LenB is no longer supported.

Smart Device Developer Notes

The Len function accepts only String and Object variables as parameters. If an Object contains a String, it will return the length of the String. If a parameter is a NULL Object reference, the function returns zero. If an Object contains any other type, an exception is thrown.

See also

Len(Char) Len(Char) Len(Char) Len(Char)

Returns an integer containing either the number of characters in a string or the nominal number of bytes required to store a variable.

public:
 static int Len(char Expression);
public static int Len (char Expression);
static member Len : char -> int
Public Function Len (Expression As Char) As Integer

Parameters

Expression
Char Char Char Char

Any valid String expression or variable name. If Expression is of type Object, the Len function returns the size as it will be written to the file by the FilePut function.

Returns

An integer containing either the number of characters in a string or the nominal number of bytes required to store a variable.

Examples

This example uses Len to return the number of characters in a string.

' Initializes variable.
Dim testString As String = "Hello World"
' Returns 11.
Dim testLen As Integer = Len(testString)

Remarks

With user-defined types and Object variables, the Len function returns the size as it will be written to the file by the FilePut function. If an Object contains a String, it will return the length of the string. If an Object contains any other type, it will return the size of the object as it will be written to the file by the FilePut function.

The VBFixedString attribute can be applied to string fields in objects to indicate the size of the string, in bytes, when written to disk. The Len function uses the VBFixedString attribute, if available, when determining the size of Object variables.

Note

The Len function may not be able to determine the actual number of storage bytes required when used with variable-length strings in user-defined data types.

Note

The LenB function in earlier versions of Visual Basic returns the number of bytes in a string rather than characters. It is used primarily for converting strings in double-byte character set (DBCS) applications. All current Visual Basic strings are in Unicode, and LenB is no longer supported.

Smart Device Developer Notes

The Len function accepts only String and Object variables as parameters. If an Object contains a String, it will return the length of the String. If a parameter is a NULL Object reference, the function returns zero. If an Object contains any other type, an exception is thrown.

See also

Len(Byte) Len(Byte) Len(Byte) Len(Byte)

Returns an integer containing either the number of characters in a string or the nominal number of bytes required to store a variable.

public:
 static int Len(System::Byte Expression);
public static int Len (byte Expression);
static member Len : byte -> int
Public Function Len (Expression As Byte) As Integer

Parameters

Expression
Byte Byte Byte Byte

Any valid String expression or variable name. If Expression is of type Object, the Len function returns the size as it will be written to the file by the FilePut function.

Returns

An integer containing either the number of characters in a string or the nominal number of bytes required to store a variable.

Examples

This example uses Len to return the number of characters in a string.

' Initializes variable.
Dim testString As String = "Hello World"
' Returns 11.
Dim testLen As Integer = Len(testString)

Remarks

With user-defined types and Object variables, the Len function returns the size as it will be written to the file by the FilePut function. If an Object contains a String, it will return the length of the string. If an Object contains any other type, it will return the size of the object as it will be written to the file by the FilePut function.

The VBFixedString attribute can be applied to string fields in objects to indicate the size of the string, in bytes, when written to disk. The Len function uses the VBFixedString attribute, if available, when determining the size of Object variables.

Note

The Len function may not be able to determine the actual number of storage bytes required when used with variable-length strings in user-defined data types.

Note

The LenB function in earlier versions of Visual Basic returns the number of bytes in a string rather than characters. It is used primarily for converting strings in double-byte character set (DBCS) applications. All current Visual Basic strings are in Unicode, and LenB is no longer supported.

Smart Device Developer Notes

The Len function accepts only String and Object variables as parameters. If an Object contains a String, it will return the length of the String. If a parameter is a NULL Object reference, the function returns zero. If an Object contains any other type, an exception is thrown.

See also

Len(Boolean) Len(Boolean) Len(Boolean) Len(Boolean)

Returns an integer containing either the number of characters in a string or the nominal number of bytes required to store a variable.

public:
 static int Len(bool Expression);
public static int Len (bool Expression);
static member Len : bool -> int
Public Function Len (Expression As Boolean) As Integer

Parameters

Expression
Boolean Boolean Boolean Boolean

Any valid String expression or variable name. If Expression is of type Object, the Len function returns the size as it will be written to the file by the FilePut function.

Returns

An integer containing either the number of characters in a string or the nominal number of bytes required to store a variable.

Examples

This example uses Len to return the number of characters in a string.

' Initializes variable.
Dim testString As String = "Hello World"
' Returns 11.
Dim testLen As Integer = Len(testString)

Remarks

With user-defined types and Object variables, the Len function returns the size as it will be written to the file by the FilePut function. If an Object contains a String, it will return the length of the string. If an Object contains any other type, it will return the size of the object as it will be written to the file by the FilePut function.

The VBFixedString attribute can be applied to string fields in objects to indicate the size of the string, in bytes, when written to disk. The Len function uses the VBFixedString attribute, if available, when determining the size of Object variables.

Note

The Len function may not be able to determine the actual number of storage bytes required when used with variable-length strings in user-defined data types.

Note

The LenB function in earlier versions of Visual Basic returns the number of bytes in a string rather than characters. It is used primarily for converting strings in double-byte character set (DBCS) applications. All current Visual Basic strings are in Unicode, and LenB is no longer supported.

Smart Device Developer Notes

The Len function accepts only String and Object variables as parameters. If an Object contains a String, it will return the length of the String. If a parameter is a NULL Object reference, the function returns zero. If an Object contains any other type, an exception is thrown.

See also

Len(Int32) Len(Int32) Len(Int32) Len(Int32)

Returns an integer containing either the number of characters in a string or the nominal number of bytes required to store a variable.

public:
 static int Len(int Expression);
public static int Len (int Expression);
static member Len : int -> int
Public Function Len (Expression As Integer) As Integer

Parameters

Expression
Int32 Int32 Int32 Int32

Any valid String expression or variable name. If Expression is of type Object, the Len function returns the size as it will be written to the file by the FilePut function.

Returns

An integer containing either the number of characters in a string or the nominal number of bytes required to store a variable.

Examples

This example uses Len to return the number of characters in a string.

' Initializes variable.
Dim testString As String = "Hello World"
' Returns 11.
Dim testLen As Integer = Len(testString)

Remarks

With user-defined types and Object variables, the Len function returns the size as it will be written to the file by the FilePut function. If an Object contains a String, it will return the length of the string. If an Object contains any other type, it will return the size of the object as it will be written to the file by the FilePut function.

The VBFixedString attribute can be applied to string fields in objects to indicate the size of the string, in bytes, when written to disk. The Len function uses the VBFixedString attribute, if available, when determining the size of Object variables.

Note

The Len function may not be able to determine the actual number of storage bytes required when used with variable-length strings in user-defined data types.

Note

The LenB function in earlier versions of Visual Basic returns the number of bytes in a string rather than characters. It is used primarily for converting strings in double-byte character set (DBCS) applications. All current Visual Basic strings are in Unicode, and LenB is no longer supported.

Smart Device Developer Notes

The Len function accepts only String and Object variables as parameters. If an Object contains a String, it will return the length of the String. If a parameter is a NULL Object reference, the function returns zero. If an Object contains any other type, an exception is thrown.

See also

Applies to