Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calling DLL(s) in vb6 1

Status
Not open for further replies.

amber1111

MIS
May 1, 2001
15
0
0
US
I have to migrate code to vb. I am quite sure that I don't have to rewrite the DLLs. All I have to do is call the DLLs in vb6.
How do I call DLL(s) in VB
 
Register the dll on the machine you will use it on. For performance, you should early bind the dll. To do this,go to Project menu and select references. Check the name of the dll that you want. In your code:

Dim objObjectName as NameOfYouDLL
'after you type 'As' it should bring up the
dll in the intelisense.

set objObjectName = CreateObject("NameOfYouDLL")

'when you are done using it, remove it from memory:
If Not objObjectName Is Nothing then
Set objObjectName = Nothing
End if
 
Woyler's answer presupposes that the DLLs are Active X (COM) DLLs. Is this the case?
 
If you are not using ActiveX/COM DLLs, and you only want to use exported APIs, then you will need to write Declare statements for each of the APIs that you wish to use. - Jeff Marler B-)
 
To answer strongm's question...the answer is no the dlls are not active(COM) dlls. I believe they are regular dlls written in C
 
nice call strongm. I didnt take my time on this. Thanks
 
Woyler does that mean you first answer was not correct? What is the proper route to take?
 
The problem with C DLLs is two-fold. Firstly, if you didn't write them and don't have the source code (or an appropriate type library) then the exercise is not straight-forward at all. The second issue (again assuming no apprporiate type library) is that if the original author did not expect the DLLs to be called by VB they may not have exported compatible function headers.

Assuming that you've beaten both these issues you probably want to have a look at the API Text Viewer to get a feel for how you can make declarations for external DLLs (in the end, all the Win32 API is is a set of DLLs with functions that you can call).

Mike
 
First of all I'd like to say, I'm not responding to this post in particular..

Second.. YOU GUYS ARE THE GREATEST ! When I was at my last job (contract, it ended) -- I found you guys.. you were
an immense help... I LOVE YOU GUYS ! (all senimental and stuff. sniff sniff.)

BTW .. I do have a basic question:

What are DLL's in VBASIC5,6, and how do you use them?

I read in a simple VBASIC5 manual that they were used for
drivers -- and stuff you didn't want in memory all the time
and to be able to reuse them and call them as needed..
but perhaps you could elaborate a little.. . . .

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top