vb.net remove method

  • Thread starter Thread starter wk6pack
  • Start date Start date
W

wk6pack

Hi,

I'm trying to use the remove method on a string but it doesnt seem to change
it.

name.remove(instr(name," ")-1,1)

If name = bon jovi, I would like bonjovi but I get bon jovi in the msgbox to
display it. I thought it suppose to remove the character space?

Am I doing something wrong?

thanks,
Will
 
Are you assigning the answer to anything?

name = name.remove(instr(name," ")-1,1)

Chris
 
thanks Chris. My bad. I assumed it would place it back into name. Not
enough sleep.

thanks again.
Will
 
Remove + Instr will only remove one occurance. How about using Replace
instead of Remove/InStr?

name = name.Replace(" ", String.Empty);

That's assuming you'd want "Jon Bon Jovi" to become "JonBonJovi" rather than
"JonBon Jovi"
 
That'll be easier. Thanks.

Will
Sean Hederman said:
Remove + Instr will only remove one occurance. How about using Replace
instead of Remove/InStr?

name = name.Replace(" ", String.Empty);

That's assuming you'd want "Jon Bon Jovi" to become "JonBonJovi" rather than
"JonBon Jovi"
 
Back
Top