?
Solved

VB6  calling created DLL

Posted on 2004-09-01
6
Medium Priority
?
369 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
Technology Partners: 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month12 days, 7 hours left to enroll

777 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