Could anyone let me know how to get the value of a mouse button that fires an event that does not pass which button it was.
Printable View
Could anyone let me know how to get the value of a mouse button that fires an event that does not pass which button it was.
You meaning Click event? In it that isn't possible (except if there's a way in API), but in MouseDown and MouseUp subs you can find Button.
Example: (start a new project and paste following into the code)
Heh, looks like other people were little slower than me :)Code:Private Sub Form_MouseDown (Button As Integer, Shift As Integer, X As Integer, Y As Integer)
Select Case Button 'Start a case
Case 0 'Nothing pushed
Exit Sub
Case 1 'Left mouse button pushed
Caption = "You pushed me with left mouse button!"
Case 2 'Right mouse button pushed
Caption = "You pushed me with right mouse
button!"
Case 3 'Both mouse buttons pushed
Caption = "You pushed me with both mouse
buttons!"
End Select
End Sub
Hope this helps,
[Edited by MerryVIP on 10-18-2000 at 08:09 AM]
Take a look at this thread.
The values for the mouse buttons are
vbLeftButton (1)
vbRightButton (2)
vbMiddleButton (4)
For example:
More about that in the MSDN Online Help - MouseEvent -Code:Private Sub Form_MouseDown(Button As Integer, Shift As Integer, _
X As Single, Y As Single)
On Error Resume Next
If Button = vbRightButton Then
MsgBox "Right Button"
ElseIf Button = vbLeftButton Then
MsgBox "Left Button"
End If
End Sub
The API call did it, thanks!