Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

ActiveX DLL Help required

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Best way to parse out a json string in VB6? 10 218
Error with a code discussed on this page 5 30
Dinamic report to Crosstab query 9 33
Set WorkSheet  not Working 9 38
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

840 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