|
-
Apr 24th, 2005, 10:10 PM
#1
Thread Starter
Lively Member
Chr() - Very weird [Resolved]
I'm making a calculator that receives input through the form's KeyUp event. I created a Select Case to know what characters were input like this:
VB Code:
Private Sub Form_KeyUp(KeyCode As Integer, Shift As Integer)
Select Case Chr(KeyCode)
Case "0"
This works fine when I type with the numbers on top of the letter keys, but when I use the numbers to the right of the keyboard, Chr() returns some weird characters, like 96 (`).
How can I know what characters were typed down for real?
Thank you.
Last edited by UTGrim; Apr 24th, 2005 at 10:33 PM.
-
Apr 24th, 2005, 10:14 PM
#2
Re: Chr() - Very weird
You will have to select case on all possible key codes and since the number above the letter keys are different
keys from the number pad. You might try the KeyPres event since its parameter is KeyAscii and not the actual
key but its equilivalent ascii character code.
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 
-
Apr 24th, 2005, 10:27 PM
#3
Fanatic Member
Re: Chr() - Very weird
This comes from a working pgm.
It is in the Form's Keydown event.
It will detect the normal digit keys, and the numeric keypad keys.
VB Code:
Select Case KeyCode
Case Asc("0"), 96
lblQuickLeadAccess.Caption = lblQuickLeadAccess.Caption & 0
Case Asc("1"), 97
lblQuickLeadAccess.Caption = lblQuickLeadAccess.Caption & 1
Case Asc("2"), 98
lblQuickLeadAccess.Caption = lblQuickLeadAccess.Caption & 2
Case Asc("3"), 99
lblQuickLeadAccess.Caption = lblQuickLeadAccess.Caption & 3
Case Asc("4"), 100
lblQuickLeadAccess.Caption = lblQuickLeadAccess.Caption & 4
Case Asc("5"), 101
lblQuickLeadAccess.Caption = lblQuickLeadAccess.Caption & 5
Case Asc("6"), 102
lblQuickLeadAccess.Caption = lblQuickLeadAccess.Caption & 6
Case Asc("7"), 103
lblQuickLeadAccess.Caption = lblQuickLeadAccess.Caption & 7
Case Asc("8"), 104
lblQuickLeadAccess.Caption = lblQuickLeadAccess.Caption & 8
Case Asc("9"), 105
lblQuickLeadAccess.Caption = lblQuickLeadAccess.Caption & 9
End Select
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
|