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.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.