[RESOLVED] [2005] How to replace "ç" and "é" when user inputs them into a textbox?
Hi!!!
I have a textbox that has a different font so when you input the character "ç" you don't see a "ç" in the text u see another symbol (a down black arrow).
When the user inputs the characters "ç" and/or "é" into the textbox I want to replace them with another characters or a string. How can i do that?
Re: [2005] How to replace "ç" and "é" when user inputs them into a textbox?
you can use the .Replace function in the KeyPress event. I dont know the keychar for the downarrow so I used a v.
VB.NET Code:
Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
If e.KeyChar = "ç" Then
CType(sender, TextBox).Text.Replace("ç", "v")
End If
End Sub
Re: [2005] How to replace "ç" and "é" when user inputs them into a textbox?
Actually, if I'm not mistaken the KeyPress event is raised BEFORE the Text changes, so using Replace on the Text would be no good. From .NET 2.0 the KeyPressEventArgs.KeyChar property is not ReadOnly so you can just do this:
vb.net Code:
If e.KeyChar = "ç"c
e.KeyChar = "v"c
End If
Re: [2005] How to replace "ç" and "é" when user inputs them into a textbox?
You forgot the "Then". :D
Plus, we forgot to mention that if you dont have the same local then the char will not eval the ç correctly as it will be a different code and not match.
Re: [2005] How to replace "ç" and "é" when user inputs them into a textbox?
I didn't forget anything. I intended to provide incorrect and incomplete information all along. ;) :D
Re: [2005] How to replace "ç" and "é" when user inputs them into a textbox?
just a detail, this "ç"c is so that VB treats "ç" as a char right?
Re: [2005] How to replace "ç" and "é" when user inputs them into a textbox?
A single character enclosed in double quotes with lower case 'c' suffix is a Char literal, yes.