Visual Basic supports three major ActiveX components:
.ocx
file.
ActiveX Documents (pp. 354-358)
An ActiveX document is very easy to create; select File -> New Project, and instead of accepting the default "Standard EXE", select "ActiveX Document EXE". Now you can create a Visual Basic project as usual.
ActiveX documents are different from other projects, though, in two ways:
1. ActiveX documents only have one form (which isn't really a form), and rather than using the Form_Load
procedure for code executed when the form is loaded, you use the Initialize
procedure.
2. If you Run your program, you won't see anything. ActiveX documents must be run from within a web browser (preferrably Internet Explorer).
Once you've created your ActiveX document and saved it as a .vbd
file (note that the entire project is saved in that file; there are no forms per se), you can open it from Internet Explorer (version 3.0 or greater), and Netscape (4.0 or later?). Just type the filename into the Address: field in the web browser, and your project will pop up.
ActiveX Controls (pp. 358-366)
An ActiveX control project is much like any other project; you have a form-like "palette" on which you can add controls, and write code to control what happens behind the controls.
However, there are some differences here. When you compile your project, you'll compile it into a .ocx
file, not a .exe
. You also can't "run" your control; you have to comple it into a .ocx
file and use it in another project to test it.
Once you compile your project, the name of that project will appear in your Components list, and can be added to any project.
ActiveX DLLs (pp. 366-368)
When you create a DLL you start with an empty project and add Modules. You then define subroutines and functions as desired, and compile the project. You now have a DLL, it's that simple.