Solved

ActiveX DLL Help required

Posted on 2006-10-24
1
174 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
[X]
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
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: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone 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

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

735 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