Browse DevX
Sign up for e-mail newsletters from DevX

Tip of the Day
Language: Visual Basic
Expertise: Beginner
Oct 1, 1996



Building the Right Environment to Support AI, Machine Learning and Deep Learning

Copying Controls and Code

Is there a way to easily copy all the event code for a control from one form to another or even within the same form. As an example I have a datagrid with a bunch of event routines. I want to create another grid (on another form in a different 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.
DevX Pro
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date