locked
How to remove spaces in a textbox? RRS feed

  • Question

  • Hi all,

    I want to remove all spaces from a text box and i know that there are similar

    questions on this forum but the replace and the trim method just don't work.

    i used both textbox1.text(" ","") and textbox1.text.trim() but none of them worked for me!

    What is wrong? ( i use visual basic 2008 express eddition)

    thanks!


    Friday, August 5, 2011 10:58 PM

Answers

  • TextBox1.Text = TextBox1.Text.Replace(" ", "")
    

    • Proposed as answer by Carmelo La Monica Saturday, August 6, 2011 9:32 PM
    • Marked as answer by TsopTsop Sunday, August 7, 2011 9:19 PM
    Friday, August 5, 2011 11:39 PM

All replies

  • TextBox1.Text = TextBox1.Text.Replace(" ", "")
    

    • Proposed as answer by Carmelo La Monica Saturday, August 6, 2011 9:32 PM
    • Marked as answer by TsopTsop Sunday, August 7, 2011 9:19 PM
    Friday, August 5, 2011 11:39 PM
  • You should assign the returned value to the TextBox1.Text 
    TextBox1.Text = TextBox1.Text.Replace(" ", "")
    Friday, August 5, 2011 11:47 PM
  • thanks, that was it!

     

    Sunday, August 7, 2011 9:19 PM