If I understood well what you meant you could (for example) do it like this :
First you create a Module which has the code for the Button-Click-Handler :
Module TestModul
Public Sub ClickHandler(sender As Object, e As System.EventArgs)
Dim mySender As Control = sender
MessageBox.Show(mySender.Name + vbCrLf + mySender.Parent.Name)
End Sub
End Module
Now, on each of your Forms you need to have the following script :
Protected Overrides Sub OnVisibleChanged(e As System.EventArgs)
MyBase.OnVisibleChanged(e)
If Me.Visible Then
For Each myControl As Control In Me.Controls
If myControl.GetType Is GetType(Button) Then
AddHandler myControl.Click, AddressOf TestModul.ClickHandler
End If
Next
Else
For Each myControl As Control In Me.Controls
If myControl.GetType Is GetType(Button) Then
RemoveHandler myControl.Click, AddressOf TestModul.ClickHandler
End If
Next
End If
End Sub
Of course severall other solutions are possible.
Also it could be a good idea to build a baseform which has this method and all forms in your project derive from this baseform. In this case they automaticly get this function.
The Handler-Method in TestModul will do what you want to be done ...