[RESOLVED] replacing characters in textbox (including special characters)
Hi,
Please help me a little bit as I'm stuck.
I have two textboxes. I type in one of them and the text gets copied in real time into another textbox. There is one catch. I need to replace specific character with something else.
If I enter a quote " in textbox1, it has to be replaced with \" in textbox2.
I started with something like the below code, but obviously this does not work (tried different stuff - this is for demonstration only). In the example below 'a' represents " , and 'b' represents \"
Code:
Private Sub TextBox1_KeyUp(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.KeyUp
TextBox2.Text = TextBox1.Text
If TextBox2.Text.Contains("a") Then
TextBox2.Text.Replace("a", "b")
End If
End Sub
In other words... whenever I enter the quote character into the textbox1 I want it to be replaced in textbox2 with a backslash+quote.
Example of my goal:
text in textbox1: Where "Glogow" is?
text in textbox2: Where \"Glogow\" is?
Can this be done ?
Re: replacing characters in textbox (including special characters)
try this:
vb Code:
TextBox2.Text = TextBox2.Text.Replace("""", "\""")
Re: replacing characters in textbox (including special characters)
Thanks a lot .paul.
I cannot believe this is so simple :o
issue resolved