Making ActiveX DLLs in Visual Basic
This tutorial
should give you an insight into making Dlls in VB. I've got VB5
Professional and the project option
I choose is ActiveX DLL
Once you've loaded
up VB and chosen to make an ActiveX DLL, the project template
will start up, and in it
you will have a class file, probably called 'Class1'. Inside your
dll you can have more than one class file and to
make it look more professional to people who will use you dll,
rename these class files to something more
meaningful than 'Class1', for the example we'll call it
"ClsAdvert"
The test project we are going to make is to simply display a message box which looks like:
If you've used
Classes before you've probably tried to be clever and have
already done it, well, why are you
reading this then? Anyway, type the following code into the class
file:
Public
Sub ShowAdvert()
Msgbox "Go to
www.oocities.org/comawhite_uk",vbCritical
,"Must!"
End Sub
Ok, now we have to
do some stupid windows thing, click on Project->Project1
Properties, then click on Compile
and enter the following number in the DLL base address:
&H10900000
This is a random number I chose, to make one, keep the &H1 there, then add a 3 digit number, the 4 last digits must be zeros as the DLL has to be loaded at the start of a 64K boundary. Next, click on the General tab, then on Unattended execution.
Now your DLL is ready to compile...
Using The DLL
These DLLs aren't true WindowsDLLs, they are something Microsoft did with ActiveX, so there is a special way of using them, heres how:
1)Start a new project
2)Go to Project->References and click, a dialog box will open looking like this:
3)Look down the list to see if it is listed there(probably called Project1), if you can't find it or can't be bothered looking them click on "Browse" and find it that way.
4)Once you have found it click OK to be returned to the main project view, rename the project(to avoid conflict with the DLL)
5)Create a command button, colour it, resize it, whatever you want, then enter the code below:
Dim
XYZ as New Project1
Private Sub Command1_Click()
Project1.ShowAdvert
End Sub
6) Run the app and click on the command button, if it works the message box should appear which nicely advertises this website
If you have any problems email me, my version of the project is available here for download if you're stuck