Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Removing Trailing Spaces

Status
Not open for further replies.

SmirnoffBlu

Programmer
May 25, 2001
13
0
0
GB
I would like to know how I can remove all the trailing spaces from variable length data in a text field using the Right$ function.
 
This is from the online help - hope it helps!
LTrim, RTrim, and Trim Functions Example
This example uses the LTrim function to strip leading spaces and the RTrim function to strip trailing spaces from a string variable. It uses the Trim function to strip both types of spaces.

Dim MyString, TrimString
MyString = &quot; <-Trim-> &quot; ' Initialize string.
TrimString = LTrim(MyString) ' TrimString = &quot;<-Trim-> &quot;.
TrimString = RTrim(MyString) ' TrimString = &quot; <-Trim->&quot;.
TrimString = LTrim(RTrim(MyString)) ' TrimString = &quot;<-Trim->&quot;.
' Using the Trim function alone achieves the same result.
TrimString = Trim(MyString) ' TrimString = &quot;<-Trim->&quot;.
 
Why don't you start from the Left$ instead of the Right$.

Like this: Left(Variable, Len(Variable))
This should give you your variable... and only your variable.

I did not test this so... this is only theory.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top