Sunday, July 14, 2013

How to Use OCX Files in VB 6


1. Add the OCX component to your Visual Basic project by selecting 'Project' and then 'Components' from the menu. This will display a list of Controls, Designers and Insertable Objects that can be added to the current project. The controls displayed can be DLL or OCX files. Click the checkbox next to the name of the control to add the OCX file to the project.
2. Include the OCX control by selecting it from the toolbox, dragging it to the current form and dropping it into place on the form. This creates an instance of the OCX within the Visual Basic project.
3. Name the instance of the OCX control that you just dropped onto the form. It will be given a generic name such as 'myControl1.' Change the name to something meaningful, such as 'AwesomeButton.'
4. Code the actions to be performed by 'AwesomeButton.' The object can be referenced in code on the form by 'me.AwesomeButton.' Typing another period at the end of 'AwesomeButton' will display a list of functions available to the current application. These functions were defined by the programmer in the code for the 'AwesomeButton' control.
5. Remove an OCX from an active project by deleting the object from the form and deleting the code that references the object. Completely remove the OCX reference to the project by un-checking the checkbox next to the name of the control in the 'Components' window where the control was added.