-
Oct 20th, 2005, 12:33 PM
#1
Thread Starter
Fanatic Member
KeyAscii Chart(resolved)
Hello,
Does anyone have a chart for the KeyAscii values for each key on the keyboard? It'd be greatly appreciated if you sent me it
Last edited by paralinx; Oct 20th, 2005 at 01:15 PM.
-
Oct 20th, 2005, 12:36 PM
#2
Re: KeyAscii Chart
Is this what you mean?
Code:
If you type "vbKey" and then press Ctrl+Space, you get a dropdown list of all the constants.
vbKeyLButton Left Mouse Button
vbKeyRButton Right Mouse Button
vnKeyCancel Cancel Key
vbKeyMButton Middle Mouse button
vbKeyBack Back Space Key
vbKeyTab Tab Key
vbKeyClear Clear Key
vbKeyReturn Enter Key
vbKeyShift Shift Key
vbKeyControl Ctrl Key
vbKeyMenu Menu Key
vbKeyPause Pause Key
vbKeyCapital Caps Lock Key
vbKeyEscape Escape Key
vbKeySpace Spacebar Key
vbKeyPageUp Page Up Key
vbKeyPageDown Page Down Key
vbKeyEnd End Key
vbKeyHome Home Key
vbKeyLeft Left Arrow Key
vbKeyUp Up Arrow Key
vbKeyRight Right Arrow Key
vbKeyDown Down Arrow Key
vbKeySelect Select Key
vbKeyPrint Print Screen Key
vbKeyExecute Execute Key
vbKeySnapshot Snapshot Key
vbKeyInsert Insert Key
vbKeyDelete Delete Key
vbKeyHelp Help Key
vbKeyNumlock Delete Key
vbKeyA through vbKeyZ are the key code constants for the alphabet
vbKey0 through vbKey9 are the key code constants for numbers
vbKeyF1 through vbKeyF16 are the key code constants for the function keys
vbKeyNumpad0 through vbKeyNumpad9 are the key code constants for the numeric key pad
Math signs are:
vbKeyMultiply - Multiplication Sign (*)
vbKeyAdd - Addition Sign (+)
vbKeySubtract - Minus Sign (-)
vbKeyDecimal - Decimal Point (.)
vbKeyDivide - Division sign (/)
vbKeySeparator - Enter (keypad) sign
-
Oct 20th, 2005, 12:43 PM
#3
Thread Starter
Fanatic Member
Re: KeyAscii Chart
yes exactly thank you. How would I work these functions into my form. I tried something like:
VB Code:
Private Sub Form_KeyPress(KeyAscii as Integer)
Select Case KeyAscii
Case vbKeyReturn
msgbox "Return"
End Select
End Sub
But that does not work.
-
Oct 20th, 2005, 12:48 PM
#4
Re: KeyAscii Chart
Originally Posted by paralinx
yes exactly thank you. How would I work these functions into my form. I tried something like:
VB Code:
Private Sub Form_KeyPress(KeyAscii as Integer)
Select Case KeyAscii
Case vbKeyReturn
msgbox "Return"
End Select
End Sub
But that does not work.
You would be better off using them with a control like a textbox. KeyPress will only fire if the control has focus.
-
Oct 20th, 2005, 12:50 PM
#5
Thread Starter
Fanatic Member
Re: KeyAscii Chart
Oh, well what would I use for the form. Form_KeyDown? Because I'm trying to make a command button move with my arrow keys
-
Oct 20th, 2005, 12:41 PM
#6
Re: KeyAscii Chart
In MSDN Help there is a topic named ASCII Character Codes that lists them.
-
Oct 20th, 2005, 12:45 PM
#7
Re: KeyAscii Chart
You can also display them as they are on your system.
VB Code:
Option Explicit
Private Sub Command1_Click()
Dim i As Integer
For i = 0 To 255
Debug.Print "ASCII "; i & " : " & Chr(i)
Next
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
-
Oct 20th, 2005, 12:49 PM
#8
Re: KeyAscii Chart
what goes wrong with your code?
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
-
Oct 20th, 2005, 12:51 PM
#9
Re: KeyAscii Chart
btw I dont think the form will capture a return..
try your code in a textbox keypress
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
-
Oct 20th, 2005, 12:57 PM
#10
Thread Starter
Fanatic Member
Re: KeyAscii Chart
try this code in a blank project and tell me if it works for you:
Code:
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
On Error Resume Next
Select Case KeyCode
Case vbKeyEnter
MsgBox "Enter Key Pressed"
Case vbKeyBackSpace
MsgBox "Delete Key Pressed"
Case vbKeyA
MsgBox "A Key Pressed"
End Select
End Sub
-
Oct 20th, 2005, 01:01 PM
#11
Re: KeyAscii Chart
I don't think there are vbKeyEnter or vbKeyBackspace, but there are vbKeyReturn and vbKeyDelete.
-
Oct 20th, 2005, 01:02 PM
#12
Thread Starter
Fanatic Member
Re: KeyAscii Chart
Yeah I fixed that I know why the above code (with the correct KeyAscii assignments) doesn't work. I have a command button and the focus is set on the command button and not the form. Is there a way to set focus to the form..?
-
Oct 20th, 2005, 01:15 PM
#13
Thread Starter
Fanatic Member
Re: KeyAscii Chart
nevermind got it to work
thanks for ya'lls help
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
|