
Detectar ALT key
Publicado por Carlos (79 intervenciones) el 23/11/2006 12:22:04
Tengo un form con un Grid que muestra el contenido de una tabla. Necesito saber como puedo detectar cuando el operador presiona la tecla ALT. Busque ayuda en el MSDN y encontré esto pero no me ayuda, no funciona:
Open a new project and add the variable ShiftTest to the Declarations section of the form:
Dim ShiftTest as Integer
Add the following code to the form's MouseDown event:
Private Sub Form_MouseDown(Button As Integer, _
Shift As Integer, X As Single, Y As Single)
ShiftTest = Shift And 7
Select Case ShiftTest
Case 1 ' or vbShiftMask
Print "You pressed the SHIFT key."
Case 2 ' or vbCtrlMask
Print "You pressed the CTRL key."
Case 4 ' or vbAltMask
Print "You pressed the ALT key."
Case 3
Print "You pressed both SHIFT and CTRL."
Case 5
Print "You pressed both SHIFT and ALT."
Case 6
Print "You pressed both CTRL and ALT."
Case 7
Print "You pressed SHIFT, CTRL, and ALT."
End Select
End Sub
Tienen alguna otra idea, please?
Gracias
Carlos Caballero
Open a new project and add the variable ShiftTest to the Declarations section of the form:
Dim ShiftTest as Integer
Add the following code to the form's MouseDown event:
Private Sub Form_MouseDown(Button As Integer, _
Shift As Integer, X As Single, Y As Single)
ShiftTest = Shift And 7
Select Case ShiftTest
Case 1 ' or vbShiftMask
Print "You pressed the SHIFT key."
Case 2 ' or vbCtrlMask
Print "You pressed the CTRL key."
Case 4 ' or vbAltMask
Print "You pressed the ALT key."
Case 3
Print "You pressed both SHIFT and CTRL."
Case 5
Print "You pressed both SHIFT and ALT."
Case 6
Print "You pressed both CTRL and ALT."
Case 7
Print "You pressed SHIFT, CTRL, and ALT."
End Select
End Sub
Tienen alguna otra idea, please?
Gracias
Carlos Caballero
Valora esta pregunta


0