Copying Controls and Code

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.

See also  Why ChatGPT Is So Important Today

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist