Check the mouse button in MouseDown event action listener : Mouse « Forms « VBA / Excel / Access / Word






Check the mouse button in MouseDown event action listener

 

Private Sub Form_MouseDown(Button As Integer,Shift As Integer,X As Single, Y As Single) 
    If Button = 1 Then ' acLeftButton 
        MsgBox "You pressed the left button." 
    ElseIf Button = 2 Then 'acRightButton 
        MsgBox "You pressed the right button." 
    ElseIf Button = 4 Then 'acMiddleButton 
        MsgBox "You pressed the middle button." 
    End If 
End Sub 

 








Related examples in the same category

1.Display Mouse Button, Shift key and Position X and Position Y
2.Writing the Form_MouseDown Event Procedure