Measurement Studio for VB6

cancel
Showing results for 
Search instead for 
Did you mean: 

Megaplus dll with visual basic

I'm trying to load a dll into a VBA form that I am writing and I can't add the dll as a reference.  After talking with a company rep, he said the dll is based on NI's CVI, and I'd have to make a wrapper for it.  How do I go about doing this?  I have little experience in writing VBA code, and none in C++, but do have programming skills. Thanks!
0 Kudos
Message 1 of 6
(7,649 Views)

Hey Tim,

What accompanying files do you have with this DLL? Do you have a .h and .lib file? This will make it much simpler to call the DLL. You mentioned that you couldn't add the DLL as a reference. What method were you using to reference this DLL? Depending on whether you have the .h and .lib file, you will have to either explicitly or implicitly link it.

 

Lars

0 Kudos
Message 2 of 6
(7,631 Views)

Yes, I do have an H and lib file....just don't know how to use them correctly 😕

 

 Using VBA 2008 DE, I go to'Projects' --> 'Add Reference', click the 'Browse' tab, navigate to the directory, select the dll, and get the error message that I've attached.

 

 

 

 

0 Kudos
Message 3 of 6
(7,624 Views)

You will not be able to select that dll as a reference, because if it has been created in CVI it is a C style dll.  You can only add ActiveX/COM dll's as a reference.  You will have to import the functions from the dll using syntax similar to the following:

 

Private Declare Function SampleFunction Lib "SampleDLL.dll" (ByVal x As Integer) As Integer

 

This line would import the C function with the following prototype:

 

int SampleFunction (int x)

 

You can then use the function in your various subroutines as needed.

 

NickB

National Instruments 

Message Edited by nickb on 09-16-2008 08:57 AM
0 Kudos
Message 4 of 6
(7,617 Views)

I think I've got it working now, thanks guys for the help. 

 

One last question:

 

Some of the functions require a pointer to be passed as a parameter.

 

for example:

MP_OpenCamera(int Head, int *CamHandle)

 

 How are you supposed to pass the address of a variable in VBA?  AddressOf operator creates function pointers/

0 Kudos
Message 5 of 6
(7,606 Views)

Hello,

 

you would pass the address of the variable as follows:

 

Private Declare Function MP_OpenCamera Lib "SampleDLL.dll" (ByVal Head As Long, ByRef CamHandle As Long)

 

If your CVI parameters are ints, it is important to pass them as longs from VBA, as integers in VBA are only 16 bit.

 

NickB

National Instruments  

0 Kudos
Message 6 of 6
(7,593 Views)