Siebel VB Language Reference > VB Language Reference >

LTrim Function

This standard VB function returns a string with leading spaces removed.





A string or string expression containing the string to be trimmed


A copy of string with leading space characters removed.


LTrim 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 typically returns a variant of vartype 8 (string). If the value of string is NULL, a variant of vartype 1 (Null) is returned.


This example trims the leading spaces from a string padded with spaces on the left.

Sub Button_Click
   Dim userinput as String
   Dim numsize
   Dim str1 as String * 50
   Dim strsize
   strsize = 50
   userinput = "abdcGFTRes"
   numsize = Len(userinput)
   str1 = Space(strsize-numsize) & userinput
   ' Str1 has a variable number of leading spaces.
   str1 = LTrim$(str1)
      ' Str1 now has no leading spaces.
End Sub

See Also

Left Function
Mid Function
Mid Statement
Right Function
RTrim Function
Trim Function

Siebel VB Language Reference