Link to home
Start Free TrialLog in
Avatar of mathprof
mathprof

asked on

Detecting a right mouse click in VB6

Of course in VB^ one can trap a mouse click. How can I distinguish whether it was a LEFT or a RIGHt mouse click?
ASKER CERTIFIED SOLUTION
Avatar of vettranger
vettranger

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Option Explicit
Private mousebutton As Integer

Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    ' remember which button was down
    mousebutton = Button
End Sub

Private Sub Form_Click()
    If mousebutton = vbLeftButton Then
        MsgBox "Left click"
    ElseIf mousebutton = vbRightButton Then
        MsgBox "Right click"
    End If
End Sub
Avatar of mathprof
mathprof

ASKER

GREAT ! Thanks. It worked.
Prof Weissman
Happy to help. :-)