I was wondering if someone could point me in the direction of preferably a working example or some good reference material for a Visual Basic Callback function to a C dll. I've read through some articles in MSDN but can't get one to work correctly. As a test I just wanted to make VB executable that on a button click would call a DLL function that in turn would call a VB function with an integer parameter specified by the DLL.

Here is the complete code (minus the .def file from my test dll)

typedef int (*LPCALLBACK)(long percent);

int __stdcall MyCFunction(LPCALLBACK lp)
{
lp(5);
return 0;
}

and here is the code from my test VB module
Option Explicit
Public Declare Function MyCFunctionLib _
"testdll" (ByVal lngFnPtr As Long) As Long

Public Function how(a As Integer)
MsgBox a
End Function

and here is the code from my main test form:

Private Sub Command1_Click()
Call MyCFunction(AddressOf how)
End Sub

When I run the executable the messagebox always comes up with -3028 and then I get an object variable or block with not set error. Can anyone help me please =). Thanks in advance. This is all in Visual Studio 6 btw.