Professional Documents
Culture Documents
/*This tutorial was made in this format by me, Cavagnaro, I DO NOT take authority for it, it was
made by a guy JDT. ALL credits goes to him.*/
This tutorial is designed for those who know nothing about creating ActiveX Dll components in
VB6.
First let’s get a brief understanding of what a Dll is and why we would use one.
Dynamic-link libraries (DLL) contain reusable functions and data. With the use of Dll files, you can
store often used functions in a common place, link to it through code, and leverage its
functionality in any of your applications without adding the common procedures to every
application. There is a down side to Dll’s; it must be installed on the users pc for your application
to access it. The up side is mostly felt in large-scale applications. A good example is the Windows
OS. Us VB programmers link to Dlls all the time (API) to get the functionality we need. Dividing
your large projects into smaller pieces using Dlls is a more efficient way to manage you projects
and fixing bugs in functions is a lot easier to just replace a small Dll than replacing a several meg
exe.
What is ActiveX?
ActiveX technology is based on the Component Object Model (COM). COM is Microsoft’s
standard that defines how software components interact with each other. COM is an
implementation of Object Oriented Programming (OOP) that is language independent, which is a
feature known as interoperability. ActiveX Dll's run in-process (uses memory space in your app).
Most importantly, VB does the real work for you. If you know VB6 then you are 95% of the way
there.
With those crash course descriptions out of the way, lets get started.
Option Explicit
Public Function ReverseString(ByRef SomeString As String) As String
ReverseString = StrReverse(SomeString)
End Function
5. Lets compile it by selecting File, in the drop-down list select Make SomeDll.dll and choose a
safe place to save it.
6. Save the project wherever you like and close it.
That’s it, the Dll is ready for a client application to use it.
Lets now make a client application to implement our newly made Dll.
Dim X As CSomeDll
'CSomeDll' is the name of the class in the DLL that has the method we want to use. We named it
this in step 2 of creating the Dll.
End Sub
As you just seen (unless you pasted the code), VB provided Intellisense to the variable X and we
see the method we added to the Dll's class object.
6. Run the program and click the button a few times to see it work.
That’s it. Simple enough yet very powerful when the situation mandates it.
You can use a Group project while designing the Dll. Highly recomended
ActiveX exe's do the same as ActiveX Dll's except exe's run out of process (their own address
space) and uses asynchronous notification.
You can make a *real* Dll in VB and declare it like the API calls you might have used but this
can't be done with ActiveX. ActiveX is much more preferable. Unless you know C, this is quite
difficult,
JDT