|
-
Nov 3rd, 2007, 04:45 PM
#1
Thread Starter
Fanatic Member
[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?
Last edited by Lasering; Nov 3rd, 2007 at 04:49 PM.
-
Nov 3rd, 2007, 06:00 PM
#2
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
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Nov 3rd, 2007, 06:30 PM
#3
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
-
Nov 3rd, 2007, 06:38 PM
#4
Re: [2005] How to replace "ç" and "é" when user inputs them into a textbox?
You forgot the "Then". 
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.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Nov 3rd, 2007, 06:43 PM
#5
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.
-
Nov 3rd, 2007, 07:40 PM
#6
Thread Starter
Fanatic Member
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?
Last edited by Lasering; Nov 3rd, 2007 at 07:46 PM.
-
Nov 3rd, 2007, 07:53 PM
#7
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.
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
|