Replacing a " " with nothing
Well in some of the data im getting back, it has alot of spaces infront of it. It looks something like:
" Data"
I just want "Data", what would I replace to make it so it only contains "Data"? At first I thought it would be something like
NewData = Replace(Data," ", VbNullstring)
but that does not work like I thought it would. Any idea?
Re: Replacing a " " with nothing
that should work 100%, try trim though
trim(data)
Re: Replacing a " " with nothing
Trim$, LTrim$, RTrim$ :)
Trim$ removes spaces from the left and right of the string, LTrim$ only from the left and RTrim$ only from the right :)
Re: Replacing a " " with nothing
Do LTrim and RTrim run faster?
Re: Replacing a " " with nothing
No clue, but if I had to guess I would say yes since Trim probably calls both... But if it doesn't actually trim one of the two (right-left) it won't affect it much? Just guessing trying to see what makes sense...
Re: Replacing a " " with nothing
Unless you are doing some crazy amount of trims in a row I don't think that you would notice any difference
Re: Replacing a " " with nothing
Trim$ is faster than Trim because it doesn't have to be converted to a string.
Re: Replacing a " " with nothing
Okay, didn't know about the Trim command :)
Anyways, since I dont really know it, im assuming it works the same as Replace in a way. I tried:
OppName1 = LTrim$(OppName)
Msgbox OppName1
The spaces were still there. Am I using it wrong?
Re: Replacing a " " with nothing
Try Trim$ and see what happens, not LTrim$
Re: Replacing a " " with nothing
Where is the data from? It's a long shot for it not to work, but there is another space (that I don't remember it's name) character code 160, that Trim won't work with...
Re: Replacing a " " with nothing
Unless he makes his own unique Trim$ statement. Could come in handy if done right.
Re: Replacing a " " with nothing
And I always thought this function I created would be useless :D
This will remove the repetative first character calling it this way, whatever it is :
VB Code:
MsgBox ATrim(S, Mid$(S, 1, 1), False)
Re: Replacing a " " with nothing
*Edit* let me try it out.
Re: Replacing a " " with nothing
If it always just a single space, you can use Mid$: String = Mid$(Text, 2)