Solved

VB6  calling created DLL

Posted on 2004-09-01
6
363 Views
Last Modified: 2010-05-02
hi

i test to create a DLL using VB6 and tried to use the same in different VB6 Projects.

i used the following as a TEST.DLL     in that function i pass a DATE value and get the Long format of date vale in the message box.

TEST.DLL
------------

Dim DT1 As Date
Public Function Wek(DT1 As Date)

    DT1 = Format(DT1, "dd.MMM.yyyy hh:mm:ss")
   
End Function

using that i created a TEST.DLL file and i registered that one. using regsvr32.


then i open a new project in VB6,   in that how to declare the created TEST.DLL and how to call that function using that DLL.



0
Comment
Question by:vinspire
  • 3
  • 2
6 Comments
 
LVL 8

Expert Comment

by:mladenovicz
ID: 11950459
Go to Project->References and add reference to the your dll. After that you can type sthg like this in the code

Dim MyObject as TEST.ObjectName

Set  MyObject = TEST.ObjectName

'-- do something

Set MyObject = Nothing
0
 
LVL 8

Expert Comment

by:mladenovicz
ID: 11950471
Ooops, I mean Set  MyObject = New TEST.ObjectName
0
 
LVL 8

Accepted Solution

by:
mladenovicz earned 50 total points
ID: 11950480
Dim MyObject as TEST.ObjectName

Set  MyObject = New TEST.ObjectName

Msgbox MyObject.Wek(Now)

Set MyObject = Nothing
0
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
LVL 11

Expert Comment

by:dbrckovi
ID: 11950566
Hi!

Try this:

1. Creating a dll:
 - start new ActiveX DLL project
 - rename project name to "TestProject"
 - change the class name to to "TestClass"
 - paste this code:
'-----------------------------------------------------------------
Public Function Wek(byVal DT1 As Date) As String
    Wek = Format(DT1, "dd.MMM.yyyy hh:mm:ss")
End Function
'------------------------------------------------------------------
 - create the TestProject.dll   (you don't have to register it for using with VB6)

2. Using the DLL.
 - start new Standard EXE project
 - Project -> References: browse to your DLL
 - create Command button
 - paste this code:
'------------------------------------------------------------------
Private Sub Command1_Click()
    Dim a As TestClass                      'reserves some memory for our class
    Set a = New TestClass                 'creates new instance of the class

    MsgBox a.Wek(Date)                    'calls the function which is the member function of TestClass class
End Sub
'-------------------------------------------------------------------
0
 
LVL 11

Expert Comment

by:dbrckovi
ID: 11950588
Ooops.  Sorry mladenovicz.    I didn't see your comments.

vinspire
Please don't accept my comment. mladenovicz has answered your question.
0
 
LVL 10

Expert Comment

by:anv
ID: 11950759
in the comment provide by mladenovicz

Go to Project->References and add reference to the your dll. After that you can type sthg like this in the code

Dim MyObject as TEST.ObjectName

Set  MyObject = TEST.ObjectName

'-- do something

Set MyObject = Nothing

replace ObjectName
 with the class name u created or where you have declared that function
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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…
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…

707 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

17 Experts available now in Live!

Get 1:1 Help Now