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

VB6  calling created DLL

Posted on 2004-09-01
6
366 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
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.

 
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
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 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…

808 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