devxlogo

Copying Controls From Form to Form

Copying Controls From Form to Form

Question:
I have a VB application that contains two forms. Form A is a Control Library that contains several Frames, Labels, Text Boxes, and Command buttons. (Note: some of these controls are third party controls.) Form B is the Main form. This form contains an SSActiveTab, with 4 tabs on it.

What I want to do is make it so that the user selects on tab 1, building a data entry form on tab 2. I know how to collect the desired controls from the Control Library, but how do I paint them onto the Main form tab?

Answer:
In VB6 a Form has a Controls collection which you can add to by passing the progid of the control. If you want to add a control that is not in the control box of the application and you want be able to catch events of the control, then declare a variable as VBControlExtender and set it to point to the control that you added:

Dim objNewControl as VBControlExtenderSet objNewControl=Controls.Add   ("Widget.Thingjet","Widget1")
See also  5 Tips For Working With An Onsite Interpreter
devxblackblue

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