how do you remove spaces from a string in vb.net?
+5
A:
to remove ALL spaces:
myString = myString.Replace(" ", "")
To remove Leading and trailing spaces:
Edit - added this removes any white space, so newlines, tabs, etc, would be removed.
myString = myString.Trim()
David Stratton
2009-10-29 18:07:50
.Trim removes white-space characters. Might not be what he wants.
ElGringoGrande
2009-10-29 18:13:16
Thank you @el.gringogrande.
David Stratton
2009-10-29 18:15:51
Replace(" ", vbNullString) may run a hair faster, and (more importantly) be a bit clearer. YMMV.
Thom Smith
2009-10-29 18:16:33