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?
mathprofAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

vettrangerCommented:
Use the mouseup or mousedown events.

They both return a button argument :

Button returns an integer that identifies the button that was pressed (MouseDown) or released (MouseUp) to cause the event. The button argument is a bit field with bits corresponding to the left button (bit 0), right button (bit 1), and middle button (bit 2). These bits correspond to the values 1, 2, and 4, respectively. Only one of the bits is set, indicating the button that caused the event.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
amebaCommented:
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
0
mathprofAuthor Commented:
GREAT ! Thanks. It worked.
Prof Weissman
0
vettrangerCommented:
Happy to help. :-)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.