Export (0) Print
Expand All

Strings.Len Method

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

Namespace:  Microsoft.VisualBasic
Assembly:  Microsoft.VisualBasic (in Microsoft.VisualBasic.dll)

public static int Len(
	string Expression
)

Parameters

Expression
Type: System.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.

Return Value

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

With user-defined types and Object variables, the Len function returns the size as it will be written to a file. 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 a file.

NoteNote:

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.

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)


Silverlight

Supported in: 5, 4, 3

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Community Additions

ADD
Show:
© 2014 Microsoft