|
-
Aug 5th, 2011, 03:13 PM
#1
Thread Starter
Lively Member
[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 ?
Last edited by marl; Aug 5th, 2011 at 03:18 PM.
Reason: added an example to make the question clearer
-
Aug 5th, 2011, 03:27 PM
#2
Re: replacing characters in textbox (including special characters)
try this:
vb Code:
TextBox2.Text = TextBox2.Text.Replace("""", "\""")
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Aug 6th, 2011, 03:48 AM
#3
Thread Starter
Lively Member
Re: replacing characters in textbox (including special characters)
Thanks a lot .paul.
I cannot believe this is so simple 
issue resolved
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|