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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Deleting spaces in a string

Status
Not open for further replies.

arundahar

Programmer
Apr 27, 2001
53
GB
How do i delete all spaces in a string and replace them with the   character?
I know you can use Replace() but what if the string has more than one space in it??

E.g
"Today is Thursday , the 9th"

to

"Today is  Thursday etc...

Thanks

Arun
 
replace() will work no matter how many spaces are in the string -- it will replace every occurence with the string you specify.

:)
Paul Prewett
penny.gif
penny.gif
 
If you want to replace MULTIPLE spaces with a single space then
Code:
Dim str1
Dim str2
str1 = strData
Do 
    str2 = Replace(str1,"  "," ") ' Double to single
    if str2 = str1 then exit do
    str1 = str2
Loop
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top