Solved

ActiveX DLL Help required

Posted on 2006-10-24
1
171 Views
Last Modified: 2011-10-03
HI

I am a beginner to ActiveX DLL development.  I want to create an Active DLL in VB, with various functions that I can call from within my VB EXE application.  Does anyone know of any good online examples that I can use to learn how to achieve this, or could someone post some examples of:

a) A simple DLL with 2 functions that can be called
b) Sample code of how to reference my ActiveX DLL from within my VB application, and how to make these calls, including passing values to it.

I know if I had a good example I could work out the rest of it myself.
Many Thanks
0
Comment
Question by:icontroldev
1 Comment
 
LVL 13

Accepted Solution

by:
jmundsack earned 50 total points
ID: 17794961
1. Create a new ActiveX DLL project (this auto-creates Class1)
2. Add the following code to Class1

Option Explicit

Private mMyProperty As String

' example of property get/let
Public Property Get MyProperty() As String
    MyProperty = mMyProperty
End Property
Public Property Let MyProperty(ByVal NewValue As String)
    mMyProperty = NewValue
End Property

' example of public procedure
Public Sub DoSomething()
    ' code to do something
End Sub

' example of public function
Public Function GetSomething() As String
    'GetSomething = <something to get>
End Function

3. Give your Class and Project some names (e.g., SomeProject, SomeClass)
4. Compile the DLL (see also * below)
5. Open another VB project
6. Go to Project > References
7. Find SomeProject in the list and check the box
8. Add the following code to this project:

    Dim objSomeClass As SomeClass
    Set objSomeClass = New SomeClass
    objSomeClass.MyProperty = "Hello, World!"
    MsgBox objSomeClass.MyProperty

This should get you started....

* Before you get too deep in ActiveX, read up on the topic of "binary compatibility".  Here is an excellent article on the topic:   http://users.skynet.be/wvdd2/Compiling/compiling.html

HTH-Jon
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now