Muokkaa

Jaa


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.

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

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.

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

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.

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

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.

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

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.

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

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.

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

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(System::String ^ Expression);
public static int Len (string? Expression);
public static int Len (string Expression);
static member Len : string -> int
Public Function Len (Expression As String) As Integer

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.

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

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);
public static int Len (float Expression);
static member Len : single -> int
Public Function Len (Expression As Single) As Integer

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.

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

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.

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

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.

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

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(System::Object ^ Expression);
public static int Len (object? Expression);
public static int Len (object Expression);
static member Len : obj -> int
Public Function Len (Expression As Object) As Integer

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.

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

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);
public static int Len (long Expression);
static member Len : int64 -> int
Public Function Len (Expression As Long) As Integer

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.

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

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);
public static int Len (short Expression);
static member Len : int16 -> int
Public Function Len (Expression As Short) As Integer

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.

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

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);
public static int Len (double Expression);
static member Len : double -> int
Public Function Len (Expression As Double) As Integer

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.

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

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(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

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

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);
public static int Len (DateTime Expression);
static member Len : DateTime -> int
Public Function Len (Expression As DateTime) As Integer

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.

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

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);
public static int Len (char Expression);
static member Len : char -> int
Public Function Len (Expression As Char) As Integer

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.

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

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(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

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

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);
public static int Len (bool Expression);
static member Len : bool -> int
Public Function Len (Expression As Boolean) As Integer

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.

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

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);
public static int Len (int Expression);
static member Len : int -> int
Public Function Len (Expression As Integer) As Integer

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.

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