My events are all messed up: HELP!!!

  • Thread starter Thread starter Aaron
  • Start date Start date
A

Aaron

OK, I was working way too late tonight. I have one form with one tab
control. I have eight tabs. And hundreds of controls on those various tabs.
I don't know why I did this but anyway I cut the tab control in order to
position a panel underneath then pasted the tab control back. Now all of my
buttons (for instance) do not initiate the original Click event:
MyButton_Click but instead generate a new event MyButton_Click_1. Are there
any quick fixes here? What are my options? Thanks.
 
OK, I was working way too late tonight. I have one form with one tab
control. I have eight tabs. And hundreds of controls on those various tabs.
I don't know why I did this but anyway I cut the tab control in order to
position a panel underneath then pasted the tab control back. Now all of my
buttons (for instance) do not initiate the original Click event:
MyButton_Click but instead generate a new event MyButton_Click_1. Are there
any quick fixes here? What are my options? Thanks.
My experience with this kind of thing is that the Handles clause at
the end of the sub declaration has been removed by the editor. The
handles clause (ie, Handles Button1.Click) is what really ties the
event to the subroutine code. The name of the sub can be XXXXXX and it
would work just fine as long as the Handles clause is correct.

In order to fix this, you really just need to put the handles clause
back for each sub. It might be easier to write a quickie program or
macro to read each line of the form module and add the clause where
appropriate. If you come across Private Sub btnClose_Click and the end
does not have Handles btnClose.Click, just add it.

I only know about this because I've done the same thing. You can
probably sell an add-on that does this. There must be a market.
 
I've done the same thing. I don't know why it happens but it's very
painful! I ended up having to manually put all the events back. I
don't remember if the event methods that were originally used actually
got deleted or not. If they have, then you could be in trouble. It's
really a nightmare that the events don't travel with the cut-paste.
 
I too learned the hard way. Instead of cutting (which is the same to the os
as a delete which removes the handle) I shrink the control real small add my
panel and then drag the control on to the panel. This way it does not
delete the handles.

Brian
 
Back
Top