How to use a regular dll create using MFC Dll wizard in a vb application.
I 've created a small dll by name sum(int,int) which returns an integer .
I want to use this function in VB application.
I will be glad if any body can help,
Printable View
How to use a regular dll create using MFC Dll wizard in a vb application.
I 've created a small dll by name sum(int,int) which returns an integer .
I want to use this function in VB application.
I will be glad if any body can help,
Well, this is the way I did it:
1. Make sure you use WINAPI as the calling convention for the functions you want to export (i.e. make available from VB), like this:
2. Add a def file to your project - it's just a text file like this:Code:double WINAPI myFunc(double myVar)
Make sure there's an entry for each function you want to export.Code:LIBRARY myDLL
EXPORTS
myFunc
3. In VBA (probably the same in VB) put something like this in the declarations area:
Make sure your DLL is in your system directory.Code:Declare Function myFunc Lib "myDLL" (ByVal myVar As Double) As Double
I think that on 32-bit versions of Windows ints are 2 bytes in VB but 4 bytes in C, so you'll have to use short in your C code instead of int. Is there a 'cleaner' way of doing this? I don't know, I'm new to this.
Hope that helps.
N.
Use the long type in VB.