-
ASCII
[Originally posted by Chris]
What are the ASCII values for the arrow keys?
-
Re:ASCII
[Originally posted by Greg DeBacker]
This info is in the help file but you can also get the values by using the KeyUp, KeyDown, or KeyPress events in a VB TextBox (or other controls with these events). Put a MsgBox statement in the event, make sure the contorl has the focus, and then press the desired key to get its code.
Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
ÿ ÿ MsgBox KeyCode
End Sub
You can also use the VB KeyCode constants like...
vbKeyLButton 1 Left mouse button
vbKeyRButton 2 Right mouse button
vbKeyCancel 3 CANCEL key
vbKeyMButton 4 Middle mouse button
vbKeyBack 8 BACKSPACE key
vbKeyTab 9 TAB key
vbKeyClear 12 CLEAR key
vbKeyReturn 13 ENTER key
vbKeyShift 16 SHIFT key
vbKeyControl 17 CTRL key
vbKeyMenu 18 MENU key
vbKeyPause 19 PAUSE key
vbKeyCapital 20 CAPS LOCK key
vbKeyEscape 27 ESC key
vbKeySpace 32 SPACEBAR key
vbKeyPageUp 33 PAGE UP key
vbKeyPageDown 34 PAGE DOWN key
vbKeyEnd 35 END key
vbKeyHome 36 HOME key
vbKeyLeft 37 LEFT ARROW key
vbKeyUp 38 UP ARROW key
vbKeyRight 39 RIGHT ARROW key
vbKeyDown 40 DOWN ARROW key
vbKeySelect 41 SELECT key
vbKeyPrint 42 PRINT SCREEN key
vbKeyExecute 43 EXECUTE key
vbKeySnapshot 44 SNAPSHOT key
vbKeyInsert 45 INS key
vbKeyDelete 46 DEL key
vbKeyHelp 47 HELP key
vbKeyNumlock 144 NUM LOCK key
Grex
-
Re:ASCII
[Originally posted by Rod]
Add a TextBox using the default name Text1 a lable and two command buttons to a form.
'*** CREDIT ***
'
'This snippet was found in news group:
'microsoft.public.vb.general.discussion
'in response to 'Right click-key?'
'Reply to above question and code below was
'answered by Rick Rothstein
Option Explicit
Private Sub Command1_Click()
ÿ ÿ Unload Me
End Sub
Private Sub Command2_Click()
ÿ ÿ Text1.Text = ""
ÿ ÿ Label1.Caption = "<--- Hit any key and view key code"
ÿ ÿ Text1.SetFocus
End Sub
Private Sub Form_Load()
ÿ ÿ Text1.TabIndex = 0
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
ÿ ÿ Dim sAscii As String
ÿ ÿ sAscii = KeyAscii
ÿ ÿ Label1.Caption = sAscii & " ASCII Key Code"
ÿ ÿ Text1.Text = ""
End Sub
HTH
-
Re:ASCII
[Originally posted by Rod]
Add a TextBox using the default name Text1 a lable and two command buttons to a form.
'*** CREDIT ***
'
'This snippet was found in news group:
'microsoft.public.vb.general.discussion
'in response to 'Right click-key?'
'Reply to above question and code below was
'answered by Rick Rothstein
Option Explicit
Private Sub Command1_Click()
ÿ ÿ Unload Me
End Sub
Private Sub Command2_Click()
ÿ ÿ Text1.Text = ""
ÿ ÿ Label1.Caption = "<--- Hit any key and view key code"
ÿ ÿ Text1.SetFocus
End Sub
Private Sub Form_Load()
ÿ ÿ Text1.TabIndex = 0
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
ÿ ÿ Dim sAscii As String
ÿ ÿ sAscii = KeyAscii
ÿ ÿ Label1.Caption = sAscii & " ASCII Key Code"
ÿ ÿ Text1.Text = ""
End Sub
HTH
-
Re:ASCII
[Originally posted by David Chapman]
Arrow keys do NOT have ASCII values, nor do keys such as Ctrl, Alt, Shift.
For a table of ASCII characters see http://www.ecs.umass.edu/ece/hill/engin191.dir/ascii.html
Arrow keys do however have Key codes assigned to them in VB as Grex explained.
Dave
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
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks