Solved

ActiveX DLL Help required

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

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

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

Suggested Solutions

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

809 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