1
votes

I have inherited a load of VB6 code which has tons of individual OCX files, each of which contain a single control. I have two questions:

Firstly, Is it possible to refactor them so that I can have a single OCX file with all the OCX's in it?

Secondly, if it is possible, how do I do this?

TIA

2
What is the driving reason to merge these files? Having multiple files, on it's own, is not necessarily a "bad thing."Greg D
Hi Greg. Thanks for your question. Generally it's for maintainability. Having loads and loads makes doing a rebuild really complex.Andrew Harmel-Law

2 Answers

6
votes

Yes this is possible.

You can do this by selecting Project->Add User Control from within an existing ActiveX User Control project. From here you can choose to add a new control to the project or add an existing user control.

Also, it can certainly make sense to group related controls together into a single project, as long as you group controls according to some kind of logic. For example, the Forms 2.0 library groups "commonly-used" controls together (Textbox, Checkbox, Combobox, Label, etc.) into a single library.

1
votes

While you can have multiple controls in a single OCX, be sure to use some foresight. You don't want to clutter your toolbox with controls you very infrequently use in your VB projects to simply use those you do frequently use.

Also, bundling multiple controls in a single .ocx can add overhead in terms of app size and load time if you aren't using all of those controls. Perhaps these were in individual files for these and other reasons worthy of consideration before you proceed to re-factor this. You may wish to consult the former coder (if feasible) to determine their reasoning for doing this.