Len (programming)

From Wikipedia, the free encyclopedia

Many common programming languages operate on strings using string functions. One of the major string functions Len, returns the length of a specific string.

This function is called Len, which stands for length, in the BASIC programming language and its derivatives such as Visual Basic. It is called strlen in the C programming language and its derivatives such as PHP. In some other programming languages, the entire word "length" is written out as the name of the function. For other languages see string functions.

[edit] Usage

In Visual Basic, the prototype of the Len function is as follows:

Function Len (ByVal Str As String)

An example below shows an example of the use of Len function.

Sub Main()
   Dim Str As String
   Dim Int As Integer
   Str = InputBox("Enter a string")
   Int = Len(Str)
   MsgBox(CStr(Int))
 End Sub

This function reads a string from an input box and outputs its length.

For example, the input "Hello!" will output 6.