The code I posted takes care of "ALL" Forms from Form1. You just have to add/remove Forms from For Each frm In New Form() <strong>{Me, Form2, Form3}</strong> and done. :)
To get a better understanding about "Handlers" and adding Event Handlers to Controls/etc., see if this helps.New Project, 1 Button
Double click Button1 and you should get this:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
End Sub
Remove the Handles Button1.Click from the end and you can even .Rename Button1_Click to something more appealing to your project.
This Not only works for a Button.Click, it works for all Events, for all Controls.:)
Private Sub _myCoolBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
End Sub
Now that you have the Handler for your Button.Click, it just has nothing to Handle since we .Removed the Handles Button1.Click , thus we have to assign a Control/etc. to Handle.
Placing this in Form1_Load or anywhere, you can add a Handler to your Button1.
AddHandler Button1.Click, AddressOf _myCoolBtn_Click
Adding some sort of code to your new Event.Handler, will access that code if done properly.
Private Sub _myCoolBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
With CType(sender, Button)
MsgBox(.Name & " - " & .Text)
End With
End Sub
Here is the entire New Project's code w/1 Button on Form1.
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
AddHandler Button1.Click, AddressOf _myCoolBtn_Click
End Sub
Private Sub _myCoolBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
With CType(sender, Button)
MsgBox(.Name & " - " & .Text)
End With
End Sub
End Class
>>Thx...
Glad I could help.:)