Solved

ActiveX DLL Help required

Posted on 2006-10-24
1
170 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

762 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

19 Experts available now in Live!

Get 1:1 Help Now