Trailing spaces
Sometimes, you will find you need to remove trailing
spaces from a string. There are 3 functions for this. Trim, LTrim, RTrim. Trim
removes spaces from either end of a string. LTrim removes spaces from the left
end of a string. RTrim removes spaces from the right end of a string. They all
use the following syntax:
Trim(String)
The following code fills String1 with ' Hello
World ', then fills Text1, Text2, Text3, Text4 displaying the results of
using nothing, Trim, LTrim and RTrim respectively
'// Declare the variable
Dim sString As String
'// Fill the variable
sString = " Hello World "
'// Display plain string
Text1.Text = sString
'// Display string using Trim
Text2.Text = Trim(sString)
'// Display string using LTrim
Text3.Text = LTrim(sString)
'// Display string using RTrim
Text4.Text = RTrim(sString)
-
Posted by KöllMorgan on 14 Jan 2007
Here we go again:
After hours of debugging, I found out the only instance the first word on the second line does not get picked up is when I physically tab or hit enter and enter or type ad...
-
Posted by KöllMorgan on 14 Jan 2007
Replying to my own post...Hiya!
I found out the trick to grabbing the first word in the string using the above code:
InStr(1," " & YourString & " ", " " & YourSearc...
-
Posted by KöllMorgan on 13 Jan 2007
Hello!
Wonderful, helpful site, by the way...
I am working on a small program for a friend and noticed the below code. Works flawlessly, accept t...
Posted by koti_sastry on 06 Dec 2005
i know i am answering to an oldest question left unanswered..
but.. i just wanted to answer it..
just for some one who is searching on a specific topic ...and end up in finding only question...
-
Posted by fatwalrus on 17 Feb 2005
[b]I included a code extract here but you have to click on "read comments" to see it all.[/b]
[i]Basically it just searches the text string for 2 spaces in row, and replaces it with one space, the...