Len Function


Len Function

Class

Microsoft.VisualBasic.Strings

Syntax

     Dim result As Integer = Len(expression) 


expression (required; any)

Any valid variable name, object, or expression

Description

The Len function returns the number of characters within a string or the storage size in bytes for a given variable.

Usage at a Glance

  • If expression contains Nothing, Len returns 0.

  • For string variables, Len returns the number of characters in the string. For all other types, Len returns the number of bytes required to store the content.

  • If expression is an array, you must also specify a valid subscript. Len cannot be used to determine the total number of elements in, or the total size of, an array.

  • Len cannot accurately report the number of bytes required to store structures that contain variable-length strings. If you need to know how many bytes of storage space will be required by a structure that includes string members, you can fix the length of the strings by using the <VBFixedString(length)> attribute in the Structure statement. For details, see the Structure...End Structure Statement entry.

  • For strings, Len is functionally similar to the String data type's Length public instance method, although there are some differences for empty and nonstandard strings.

See Also

Structure...End Structure Statement, VBFixedString Attribute




Visual Basic 2005(c) In a Nutshell
Visual Basic 2005 in a Nutshell (In a Nutshell (OReilly))
ISBN: 059610152X
EAN: 2147483647
Year: 2004
Pages: 712

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net