Copying Controls and Code

Is there a way to easily copy all theevent code for a control from one form to another or even within thesame form. As an example I have a datagrid with a bunch of eventroutines. I want to create another grid (on another form in adifferent app) with all the same routines. It seems like there should be a better way than manual cut and paste.

I have no idea why it works like this, but it seems that they still haven’t fixed this behavior. You might try this:

  1. In Visual Basic, copy the controls to the new form. Make sure they are all named the same as on the source form.
  2. Make sure the original form is saved in Text Format.
  3. Open both Forms in Notepad or WordPad and manually copy all of the appropriate code. It’s quicker than VB. You can also, in VB 4, select Full Module View from the Options screen to get essentially the same view that Notepad gives you.

Share the Post:
Share on facebook
Share on twitter
Share on linkedin


Recent Articles: