[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

VB6  calling created DLL

Posted on 2004-09-01
6
Medium Priority
?
371 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
[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
  • 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 200 total points
ID: 11950480
Dim MyObject as TEST.ObjectName

Set  MyObject = New TEST.ObjectName

Msgbox MyObject.Wek(Now)

Set MyObject = Nothing
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

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…
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.
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…
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…
Suggested Courses

656 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