Siebel VB Language Reference > VB Language Reference >

Left Function

This standard VB function returns a string of a specified length copied from the beginning of another string.


Left[$](string, length)



A string, or an expression containing a string, from which a portion is to be copied


An integer representing the number of characters to copy


A substring of string, of length length, beginning at the first character of string.


If length is greater than the length of string, Left returns the whole string.

Left accepts expressions of type string. Left accepts any type of string, including numeric values, and converts the input value to a string.

The dollar sign ($) in the function name is optional. If it is included, the return type is string. Otherwise the function returns a variant of vartype 8 (string). If the value of string is NULL, a variant of vartype 1 (Null) is returned.


This example extracts a user's first name from the entire name entered.

Sub Button_Click
      Dim username as String
      Dim count as Integer
      Dim firstname as String
      Dim charspace
      charspace = Chr(32)
      username = "Chris Smith"
      count = InStr(username,charspace)
         firstname = Left(username,count)
End Sub

See Also

Len Function
LTrim Function
Mid Function
Mid Statement
Right Function
RTrim Function
Str Function
StrComp Function
Trim Function

Siebel VB Language Reference