[VB6][list/reference] VB6 Key Codes

Experienced Elementalist
Joined
Mar 31, 2007
Messages
276
Reaction score
0
Here are all the key Codes you might need in VB
what key they are for it after the ' (as it was a vb thing i though i would say what they are in a vb comment)
vbKeyControl 'CTRL Key
vbkeymenu 'ALT key
vbKeyReturn 'Enter Key (Main)
vbKeyBack 'Back Space
vbKeyTab 'Tab
vbKeyShift 'Shift
vbKeyCapital 'Caps Lock
vbKeyEscape 'Esc
vbKeySpace ' Space Bar
vbKeyPageUp ' Page Up
vbKeyPageDown ' Page Down
vbKeyEnd 'End
vbKeyHome ' Home
vbKeyLeft 'Left arrow
vbKeyUp 'Up arrow
vbKeyRight 'Right Arrow
vbKeyDown ' Down Arrow
vbKeyPrint 'Print Screen
vbKeyPause 'Pause (The one next to printscreen)
vbKeyInsert 'Insert
vbKeyDelete 'Delete (the one near insert)
vbKeyHelp 'Help
vbKeyNumlock ' Numlock
vbKeyF1 'F1
vbKeyF2 'F2
vbKeyF3 'F3
vbKeyF4 'F4
vbKeyF5 'F5
vbKeyF6 'F6
vbKeyF7 'F7
vbKeyF8 'F8
vbKeyF9 'F9
vbKeyF10 'F10
vbKeyF11 'F11
vbKeyF12 'F12
vbKeyZ 'Z
vbKeyx 'X
vbKeyc 'C
vbKeyv 'V
vbKeyb 'B
vbKeyn 'N
vbKeym 'M
vbKeya 'A
vbKeys 'S
vbKeyd ' D
vbKeyf 'F
vbKeyg 'G
vbKeyh 'H
vbKeyj 'J
vbKeyk 'K
vbKeyl 'L
vbKeyq 'Q
vbKeyw 'W
vbKeye 'E
vbKeyr 'R
vbKeyt 'T
vbKeyy 'Y
vbKeyu 'U
vbKeyi 'I
vbKeyo 'O
vbKeyp 'P
vbKeyNumpad0 'Num Pad 0
vbKeyNumpad1 'Num Pad 1
vbKeyNumpad2 'Num Pad 2
vbKeyNumpad3 'Num Pad 3
vbKeyNumpad4 'Num Pad 4
vbKeyNumpad5 'Num Pad 5
vbKeyNumpad6 'Num Pad 6
vbKeyNumpad7 ' Num Pad 7
vbKeyNumpad8 'NumPad 8
vbKeyNumpad9 'Num Pad 9
vbKeyMultiply 'Num Pad *
vbKeyAdd 'Num Pad +
vbKeySubtract 'Num Pad -
vbKeyDivide 'Num Pad /
vbKeySeparator 'Num Pad Enter
vbKeyDecimal 'Num Pad .
vbKey0 'Normal 0 from top of keyboard
vbKey1 'Normal 1 from top of keyboard
vbKey2 'Normal 2 from top of keyboard
vbKey3 'Normal 3 from top of keyboard
vbKey4 'Normal 4 from top of keyboard
vbKey5 'Normal 5 from top of keyboard
vbKey6 'Normal 6 from top ofkeybaorrd
vbKey7 'Normal 7 from top of keyboard
vbKey8 'Normal 8 from top of keybaord
vbKey9 'Normal 9 from top of keyboard
And thats them all of them
How to use (if you dont know)
Code:
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyBack Then
MsgBox " You pushed backSpace" 'That is changed to what you want it to do when they push it
End If 'Rember for every If you must have a end if
End Sub
Now For the mouse Buttons:
vbKeyLButton 'Left mouse Button
vbKeyRButton 'Right Mouse Button
vbKeyMButton 'Middal mouse Button

And to use them its a bit diffrent
Code:
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbKeyLButton Then
MsgBox " You pushed the left mouse button" 'The code you want it to do gose there
End If ' rember for every If you need End If
End Sub
And if you want it so you can push 2 keys at same time and it dose something the code for that is
Code:
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyA And vbKeyReturn Then
MsgBox "enter + A" 'or code to do here
End If
End Sub
 
Yea I'm Going Back TO Coding Rite Now But I See Alot Of People (Coders) Using Like C#

Ps I'll be Doing More TUtorials As I Remember Things

Thanx To Who Ever Changed My Title I Wasn't Sure What TO Put
 
Well VB6 You Can Do Like C# Just Knowing The Codes VB6 Is easy ANd Easy To Learn.

Offtopic: What Can i Say Go on MSN I Already Have You Your MSN is Like i_Love Rubberbands Or Something like That
 
Back