[RESOLVED] [2005] Removing a number variable of spaces at the start of a string
Hi!!!
I want to remove in a string any spaces in the begining of the string, but the string can have a variable spaces at the start and also HAS spaces in the middle and in the end. So i just want to remove the "start spaces" not the other ones and these "start spaces" can be diferent. Sometimes can only be 2 spaces and sometimes can be 5 spaces. U get the pic.
Re: [2005] Removing a number variable of spaces at the start of a string
Code:
Dim MyString as String = " HELLO WORLD"
MyString = MyString.TrimStart
Messagebox.Show(MyString)
Re: [2005] Removing a number variable of spaces at the start of a string
Look at the Trim function and see if it will do what you want. I believe there is a variant to Trim from front, back, or both. If that is not sufficient, then you might have to walk along the string removing spaces, but Trim should suffice.
Re: [2005] Removing a number variable of spaces at the start of a string
Thks a lot!!! I didnt use that function earlier because it says:
"Removes all occurrences of a set of characters specified in a array from the beginning of this instance" and it has a Parameter and no overloads. So i fought it couldn't be used without any parameters.
Re: [RESOLVED] [2005] Removing a number variable of spaces at the start of a string
true, but if you look at the return value section of the MSDN doc for this function it states:
The string that remains after all occurrences of characters in the trimChars parameter are removed from the start of the current String object. If trimChars is a null reference (Nothing in Visual Basic), white-space characters are removed instead.
Re: [RESOLVED] [2005] Removing a number variable of spaces at the start of a string
lol. Looks like i have to read more in order to get more info. Because if i've read that i woudnt ask in the first place, lool