Button1_click()

otuatail

Active member
Joined
May 25, 2011
Messages
28
Programming Experience
5-10
Hi I created my first vb.net app. Half way through I relaised that it is not a good idea to let VS use the default names for controls so I changed button1 to test1. Strange though. The app still works. I click on my now renamed test1 only to find that it goes into Button1_click(). How is this happening. surley the click event should have been re-named. How is it getting there?

Desmond
 
Your original click event looked something like this:

VB.NET:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

When you changed the name of the control, VS changes the handle to the new name, but doesn't modify the sub name itself:

VB.NET:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Test1.Click

So you can change the sub name (Button1_Click) to whatever you would like and as long as the handle is correct it will still work. The make things easier, rename your controls before you write the code.

Hope this helps
-Josh
 
Back
Top