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)

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)

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)

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)

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)

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)

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)

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)

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)

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)

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)

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)

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)

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)

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)

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)

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)

Source:
Strings.vb
Source:
Strings.vb
Source:
Strings.vb

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.

[System.CLSCompliant(false)]
public static int Len (ulong Expression);

Parameters

Expression
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.

Attributes

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.

Notitie

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.

Notitie

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

.NET 9 en andere versies
Product Versies
.NET Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1

Len(UInt32)

Source:
Strings.vb
Source:
Strings.vb
Source:
Strings.vb

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.

[System.CLSCompliant(false)]
public static int Len (uint Expression);

Parameters

Expression
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.

Attributes

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.

Notitie

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.

Notitie

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

.NET 9 en andere versies
Product Versies
.NET Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1

Len(UInt16)

Source:
Strings.vb
Source:
Strings.vb
Source:
Strings.vb

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.

[System.CLSCompliant(false)]
public static int Len (ushort Expression);

Parameters

Expression
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.

Attributes

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.

Notitie

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.

Notitie

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

.NET 9 en andere versies
Product Versies
.NET Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1

Len(String)

Source:
Strings.vb
Source:
Strings.vb
Source:
Strings.vb

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 (string? Expression);
public static int Len (string Expression);

Parameters

Expression
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.

Notitie

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.

Notitie

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

.NET 9 en andere versies
Product Versies
.NET Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1

Len(Single)

Source:
Strings.vb
Source:
Strings.vb
Source:
Strings.vb

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);

Parameters

Expression
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.

Notitie

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.

Notitie

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

.NET 9 en andere versies
Product Versies
.NET Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1

Len(SByte)

Source:
Strings.vb
Source:
Strings.vb
Source:
Strings.vb

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.

[System.CLSCompliant(false)]
public static int Len (sbyte Expression);

Parameters

Expression
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.

Attributes

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.

Notitie

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.

Notitie

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

.NET 9 en andere versies
Product Versies
.NET Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1

Len(Object)

Source:
Strings.vb
Source:
Strings.vb
Source:
Strings.vb

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 (object? Expression);
public static int Len (object Expression);

Parameters

Expression
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.

Notitie

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.

Notitie

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

.NET 9 en andere versies
Product Versies
.NET Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1

Len(Int64)

Source:
Strings.vb
Source:
Strings.vb
Source:
Strings.vb

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);

Parameters

Expression
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.

Notitie

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.

Notitie

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

.NET 9 en andere versies
Product Versies
.NET Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1

Len(Int16)

Source:
Strings.vb
Source:
Strings.vb
Source:
Strings.vb

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);

Parameters

Expression
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.

Notitie

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.

Notitie

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

.NET 9 en andere versies
Product Versies
.NET Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1

Len(Double)

Source:
Strings.vb
Source:
Strings.vb
Source:
Strings.vb

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);

Parameters

Expression
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.

Notitie

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.

Notitie

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

.NET 9 en andere versies
Product Versies
.NET Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1

Len(Decimal)

Source:
Strings.vb
Source:
Strings.vb
Source:
Strings.vb

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 (decimal Expression);

Parameters

Expression
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.

Notitie

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.

Notitie

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

.NET 9 en andere versies
Product Versies
.NET Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1

Len(DateTime)

Source:
Strings.vb
Source:
Strings.vb
Source:
Strings.vb

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);

Parameters

Expression
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.

Notitie

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.

Notitie

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

.NET 9 en andere versies
Product Versies
.NET Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1

Len(Char)

Source:
Strings.vb
Source:
Strings.vb
Source:
Strings.vb

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);

Parameters

Expression
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.

Notitie

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.

Notitie

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

.NET 9 en andere versies
Product Versies
.NET Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1

Len(Byte)

Source:
Strings.vb
Source:
Strings.vb
Source:
Strings.vb

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 (byte Expression);

Parameters

Expression
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.

Notitie

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.

Notitie

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

.NET 9 en andere versies
Product Versies
.NET Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1

Len(Boolean)

Source:
Strings.vb
Source:
Strings.vb
Source:
Strings.vb

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);

Parameters

Expression
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.

Notitie

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.

Notitie

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

.NET 9 en andere versies
Product Versies
.NET Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1

Len(Int32)

Source:
Strings.vb
Source:
Strings.vb
Source:
Strings.vb

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);

Parameters

Expression
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.

Notitie

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.

Notitie

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

.NET 9 en andere versies
Product Versies
.NET Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1