Left, Left$, LeftB, LeftB$ (functions)

Syntax

Left[$](string, length)

LeftB[$](string,length)

Description

Functions return the leftmost length characters as follows.

 

Functions

Return the leftmost length characters

 

Left and Left$

Of bytes

 

LeftB and LeftB$

From a given string

 

Left$ and Left functions return the following.

 

Function

Returns

 

Left$

String

 

Left

String variant.

 

 

The length parameter is an Integer value specifying the number of characters to return as follows.

 

 

Length is

Returns

 

 

0

Zero-length string

 

 

Greater than or equal to the number of characters in the specified string

Entire string

 

LeftB and LeftB$ functions return the following.

 

Functions

Return

 

LeftB and LeftB$

Sequence of bytes from a string containing byte data.

 

 

 

length specifies the number of bytes to return as follows.

 

 

 

Length is

Returns

 

 

 

Greater than the number of bytes in string

Entire string

 

 

 

String is Null.

Null

Comments

Left$ returns a String, whereas Left returns a String variant.

NumChars is an Integer value specifying the number of character to return. If NumChars is 0, then a zero-length string is returned. If NumChars is greater than or equal to the number of characters in the specified string, then the entire string is returned.

NULL is returned if text is NULL.

Example

This example shows the Left$ function used to change uppercase names to lowercase with an uppercase first letter.

Sub Main()
  lname$ = "WILLIAMS"
  fl$ = Left(lname$,1)
  rest$ = Mid(lname$,2,Len(lname$))
  lname$ = fl$ & LCase(rest$)
  MsgBox "The converted name is: " & lname$
End Sub

See Also

Right, Right$, RightB, RightB$ (functions)

 

 

 

 

 

More information

L