Dears,
For CTRL + N we use If KeyCode = vbKeyN And Shift = 2 Then, what will we use if we want to use N Key with ALT button
Regards
Printable View
Dears,
For CTRL + N we use If KeyCode = vbKeyN And Shift = 2 Then, what will we use if we want to use N Key with ALT button
Regards
If it's for sendkeys, I've a link in my sig which has all the key codes
If not, http://www.vbforums.com/showthread.php?t=587222 says vbAltMask is what you're looking for
Code:shift=4
Usage: If KeyCode = vbKeyN And Shift = 4 Then ~~> Alt + N :wave:
See help for KeyDown and KeyUp Events
Code:Shift = 1 : SHIFT was pressed.
Shift = 2 : CTRL was pressed.
Shift = 4 : ALT was pressed.
Shift = 3 : CTRL+SHIFT was pressed.
...
its not working in my code. I wroteif i use CTRL + X it works but if i use ALT + N its not workvb Code:
If KeyCode = vbKeyN And Shift = 4 Then 'NEW lbl_Click (0) ElseIf KeyCode = vbKeyS And Shift = 4 Then 'SAVE lbl_Click (1) ElseIf KeyCode = vbKeyC And Shift = 2 Then 'Cancel lbl_Click (2) ElseIf KeyCode = vbKeyD And Shift = 4 Then 'Delete lbl_Click (3) ElseIf KeyCode = vbKeyF And Shift = 2 Then 'Find lbl_Click (4) ElseIf KeyCode = vbKeyX And Shift = 2 Then 'Exit lbl_Click (5) End If
Where are using this code...????
i have used Lables as command Buttons and want to use with KEY CODE. i m using this code in FORM_KeyDown event
Have you set the KeyPreview property of form to True ...???
KeyPreview property of form is True, thats why CTRL + Keys is working
Is this what you want?Quote:
what will we use if we want to use N Key with ALT butt
You can check it for keydown event of textbox
Code:Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
ShiftTest = Shift And 7
If KeyCode = vbKeyN And ShiftTest = 4 Then
MsgBox "You pressed Alt+N"
End If
End Sub
I m not using this on Textbox, i need to implement it on Form