VB.net 2005 Help (Trim Function)

brewcrew814

Limp Gawd
Joined
Oct 27, 2005
Messages
134
Hello all. I was hoping someone could help me out in regards to trimming blank spaces within words or a sentance. I know you can use RTrim to trim all spaces to the right, LTtrim to trim all spaces to the left and just Trim to trim everything Left and Right. What I need is to trim a blank spot between 2 words if it exists.

I.E.
AB CDEFG

I need to turn this into ABCDEFG Excuse me for the newbie question but I need to fix some code for a guy that quit and I'm a new developer :D I was hoping there was a simple function to use that I was just overlooking. Like title says, I'm using VB.net 2005

Thanks In Advance,
J.B.
 
One way to think of the problem would be as a substitution. You want to replace space characters with nothing, effectively deleting them.

You can do this with the String.Replace method by calling it with the string to match of " " (just a space inside double quotes), and the replacement string of "", which is just two quotes -- the empty string.
 
Thanks a lot!! I guess I was over thinking this LOL. I found his function where he was doing all his replacements and just added the string.replace and the worked out great.

J.B.
 
Back
Top