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:
Code:
double WINAPI myFunc(double myVar)
2. Add a def file to your project - it's just a text file like this:
Code:
LIBRARY myDLL
EXPORTS
myFunc
Make sure there's an entry for each function you want to export.
3. In VBA (probably the same in VB) put something like this in the declarations area:
Code:
Declare Function myFunc Lib "myDLL" (ByVal myVar As Double) As Double
Make sure your DLL is in your system directory.
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.