I want to activate a sub by clicking the left mouse button but i cant make it work i tried
private sub test(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.MouseDown

but it says it doesn't work because they dont have a compatable signature

Here's a sort of workaround

Private Sub MyMouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs)
  ' Your "MouseDown"

End Sub

Private Sub Form2_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseDown
  ' Call MyMouseDown
  ' Trap left mouse button
  If e.Button = Windows.Forms.MouseButtons.Left Then
    MyMouseDown(sender, e)
  End If

End Sub

It traps form's mouse down event, checks that left button is pressed and calls a standard procedure with mouse down event's arguments.

HTH

Chris11246,
Did you notice?
This is your code:

private sub test(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.MouseDown

and this is Tem's code

Private Sub Form2_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseDown
  ' Call MyMouseDown
  ' Trap left mouse button
  If e.Button = Windows.Forms.MouseButtons.Left Then
    MyMouseDown(sender, e)
  End If
End Sub

Function Signature : It means argument (parameters), and return datatype of function or sub.

To add an event handler:
1. Select a Control or Form
2. Open Properties Windws.
3. Select Event tab.
4. Double click on the name of event you want to handle.

This article has been dead for over six months. Start a new discussion instead.