tags:

views:

167

answers:

1

Hello.

I use a button to locate a file, and it puts the location in the textbox as "C:\file.exe\" I need the "" so when a user select a folder with a space in it it wont see it as a new input.

       OpenFileDialog1.ShowDialog()
    Dim filename As String = OpenFileDialog1.FileName
    TextBox1.Text = Chr(34) & filename & Chr(34)

But later i need the same location of the textbox but without the "" (Chr(34))charachters. How can i make it so it removes those characters out of the textbox?

+2  A: 

You can remove any set of characters from a string using the .Replace method.

Dim text = TextBox1.Text.Replace(Chr(34).ToString(),String.Empty)
TextBox1.Text = text
JaredPar
When i run it i get this error "Cross-thread operation not valid: Control 'TextBox1' accessed from a thread other than the thread it was created on."
PandaNL
Very strange, when i build it, it works, but in debug it gives an error.
PandaNL