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

Remove all spaces from a string 1

Status
Not open for further replies.

Binnit

Technical User
Apr 28, 2004
627
US
How can I create a function to search through a string and remove all spaces so that

"This string has 4 spaces"
becomes
"Thisstringhas4spaces"

I have read the help relating to the Instr function but not sure how to take it forward and remove the spaces.

Any ideas?



Happiness is...not getting what you want but wanting what you have already got
 
What you need is Replace:

Replace(ThisString," ","")
 
If by "Space" you mean the literal space character (e.g. Chr(32), look up the REPLACE function and apply it accordingly. If you mean "White Space" as in all non printing characters, it is more convolouted.





MichaelRed


 
Remou - worked a treat nice and simple

MichaelRed - thanks for your post but only the simple answer required at this time as per Remou solution.

Happiness is...not getting what you want but wanting what you have already got
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top