Creating an ActiveX control, using VB6, that can be called from a VBScript
running in DIAdem.
The following document describes how to:
create an ActiveX object using VB6
register it with Windows OS
access the controls methods from DIAdem
1. Launch VB6.0 and select “ActiveX Control” from the list of new projects that can be
2. Now inside of VB there is a new project called “Project1” that has “UserControl1” as
its only user control. To create this interface we will be adding our own custom
functions behind UserControl1. You get to the code window for User Control1 by
right-clicking on the control and selecting “view code” from the context menu.
3. Enter the following code into the general declarations form of Usercontrol1:
4. Now save the project and control with names that make sense. Select “File>>Save
Project As…” in the VB window menu. You will first be prompted to give a name to
your control as shown below. For the sake of this exercise call it “TestOCX.ctl”, then
click <Save> to proceed.
5. You are now prompted to enter the name of the project. Use the same name,
“TestOCX.vbp”, for the sake of simplicity, then click <Save> to proceed.
6. You are now ready to compile the control into an OCX. Select “File>>Make
TestOCX.ocx” in the VB window menu. You will be prompted to give the control a
name, again leave the name as “TestOCX.ocx” as shown below, and click the <OK>
button to proceed.
7. VB now builds the OCX that you will use in DIAdem. You must first register the
component with the Windows operating system, though, so applications such as
DIAdem can find it. Hit <Windows Key-R> to bring up the Windows Run dialog,
8. Type in the following command into the run dialog, replacing X with the path you
saved the OCX in. Click <OK> to execute your command to register the OCX.
9. You should now get back a message box (shown below) confirming that the control
was registered properly. If the message box indicates that the registration did not take
place, then repeat the last step, checking the spelling and syntax of the command
entered, including the path to the OCX file.
10. Now that the control is registered you can try it out in DIAdem. Go to DIAdem
AUTO and create a new VBScript with the following commands:
Set objTest = CreateObject("Project1.UserControl1")
Set objTest = NOTHING
11. The above code creates a reference to the TestOCX you created with VB and gives us
access to all of it’s methods, as illustrated in the 2nd line of code where the MyAdder
function returns a result to DIAdem.