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?
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

vettrangerConnect With a Mentor Commented:
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.
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
mathprofAuthor Commented:
GREAT ! Thanks. It worked.
Prof Weissman
Happy to help. :-)
All Courses

From novice to tech pro — start learning today.