Is there a more elegant or efficient way to write some of my code?
In particular, I have a toolstrip on all of my forms. Each form has its own set of methods that essentially is doing the same thing. Is there a way to delete all of the methods save one, and then just enclose it into a switch statement for my form specific variables?
An example of what I am talking about:
'Form 1
Private Sub ExitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitToolStripMenuItem.Click
Application.Exit()
End Sub
'Form 2
Private Sub ExitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitToolStripMenuItem.Click
Application.Exit()
End Sub
Could I delete one of them, and move the other to a separate module and have it act for both form1 and form2?
Private Sub ExitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles [myWholeDangProject].ExitToolStripMenuItem.Click
Application.Exit()
End Sub
Yes, use Addhandler and AddressOf to hookup the events when the forms initialize.
and