Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating a activeX DLL using VB6

Status
Not open for further replies.

Denyson

Programmer
Mar 20, 2001
19
BR
Hi,

What I must to do to create a simple VB6 active X DLL that execute just a Sub. Please give me an example.

Thanks
Denyson
 
Well, you actually need two projects -- one for the DLL, and one to call it.

In the first project, create a new ActiveX Dll. You'll want to name your project something other than "Project1", and your class something other than "Class1". For now, use "MyProject" and "MyClass". In MyClass, add a new sub called "Increment":
[tt]
Public Sub Increment(byref A as long)
A = A + 1
End Sub
[/tt]
Compile the DLL.

Create a new project -- a new Application (ordinary EXE). On the Form1, add a new button. Double-click on the button to get to it's event code. In there, add the following code:
[tt]
Dim objMyDll as object
Dim lValue as long

lValue = 23
set objMyDll = createobject("MyProject.MyClass")

objMyDll.Increment(lValue)
Set objMyDll = nothing
Msgbox "Value is now: " & cstr(lValue)
[/tt]

Run the application. When you click on the button it will try to create an instance of MyClass, and call the Increment method. You should see a message box with the value 24 in it.

Hope this helps.

Chip H.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top