Remove Spaces From String Method
The Remove Spaces From String method removes leading spaces from a string. It returns a copy of this string with the leading spaces removed. It accepts any type of string, including numeric values, and converts the input value to a string.
If the value that the string argument contains is NULL, then this method returns a Null variant. For more information, see Variants.
Format
LTrim[$](string)
For information about the dollar sign, see Usage of the Dollar Sign.
The following table describes the arguments that you can use with this method.
Argument | Description |
---|---|
string |
A string or string expression that contains the string that this method trims. |
Example
The following example removes the leading spaces from a string:
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