Solved

VB6  calling created DLL

Posted on 2004-09-01
6
365 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
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 
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

Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

Suggested Solutions

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

803 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