Writing the Form_MouseDown Event Procedure : Mouse « Forms « VBA / Excel / Access / Word






Writing the Form_MouseDown Event Procedure

 
Private Sub Form_MouseDown(Button As Integer,Shift As Integer, X As Single, Y As Single) 
    Select Case Shift 
        Case 0 
            MsgBox "You did not press a key." 
        Case 1 ' or acShiftMask 
            MsgBox "You pressed SHIFT." 
        Case 2 ' or acCtrlMask 
            MsgBox "You pressed CTRL." 
        Case 3 
            MsgBox "You pressed CTRL and SHIFT." 
        Case 4 ' or acAltMask 
            MsgBox "You pressed ALT." 
        Case 5 
            MsgBox "You pressed ALT and SHIFT." 
        Case 6 
            MsgBox "You pressed CTRL and ALT." 
        Case 7 
            MsgBox "You pressed CTRL, ALT, and SHIFT." 
    End Select 

End Sub 

 








Related examples in the same category

1.Display Mouse Button, Shift key and Position X and Position Y
2.Check the mouse button in MouseDown event action listener