mnuFileNew.Click += mnuFileNew_Click
This is a way to assign a method to an event. Basically, this is the same as if you double-clicked on the control in the designer and added your code there. But what it really allows you to do is assign a method to a control's event anytime you want. You can also use this to change a control's event if needed in code. You can use to remove an Event assignment:
mnuFileNew.Click -= mnuFileNew_Click
If you used that, the control would no longer have a Click event. You could then reassign another method to the control as needed.
Why would you want to do this manually versus using the default event assignment? I basically just explained that...If you want to assign the same method to several controls, this is how you would do it. Also, you might need to assign a control's event after some other event happens. As an example, maybe I want to have a combobox's SelectedIndexChanged event do something special. But if I assign the method using the default method, at Form Load, the event would fire because the index of the combobox would be set to 0 immediately. Instead, after I load the combobox with my values, I can then use the above method to assign the SelectedIndexChanged event.
Last, the third example...That should work. I haven't done much VB in a while (been doing a lot of C# lately), but that is still probably not the best method. I think the correct syntax for calling a method from another in VB.Net is this:
Code:
mnuFileNew_Click(sender, New System.EventArgs()) 'If you need to pass the arguements
or
mnuFileNew_Click(Nothing, Nothing) 'If you don't care about the arguements
Hopefully that helps explain a bit more...Please let me know if you need more explanation about any of these items.
=======================================
People think it must be fun to be a super genius, but they don't realize how hard it is to put up with all the idiots in the world. (Calvin from Calvin And Hobbs)
Robert L. Johnson III
CCNA, CCDA, MCSA, CNA, Net+, A+, CHDP
C#.NET Programmer