callback Proc: need delegate obj. Pls help

S

suria`

hi
New to delegates, trying to figure out how to use a
delegate to fix a bug after upgrading code from VB6 to
VB.NET

I have the following callback proc:
' in vb 6.0

###############################################################################
Public Sub LineCallbackProc(ByVal hDevice As Long, _
ByVal dwMsg As Long, _
ByVal dwCallbackInstance As Long, _
ByVal dwParam1 As Long, _
ByVal dwParam2 As Long, _
ByVal dwParam3 As Long)
'the callbackInstance parameter contains a pointer to the
CvbTAPILine class
'this sub just routes all callbacks back to the class for handling
there
Dim PassedObj As CvbTAPILine
Dim objTemp As CvbTAPILine
Debug.Print "LineCALLBACK : dwCallbackInst = " &
dwCallbackInstance
If dwCallbackInstance <> 0 Then
'turn pointer into illegal, uncounted reference
'Debug.Print "step #1"
CopyMemory objTemp, dwCallbackInstance, 4
'Assign to legal reference
'Debug.Print "step #2"
Set PassedObj = objTemp
'Destroy the illegal reference
'Debug.Print "step #3"
CopyMemory objTemp, 0&, 4
'use the interface to call back to the class
'Debug.Print "step #4"
PassedObj.LineProcHandler hDevice, dwMsg, dwParam1, dwParam2,
dwParam3
'Debug.Print "step #5"


End If

End Sub
###############################################################################

rc = lineInitializeEx(m_hLineApp, App.hInstance, AddressOf _
LineCallbackProc, App.Title, _
m_numLines, m_HiAPI, lip)
###############################################################################


When i converted this in vb.net i get an errors stating that

'AddressOf' expression cannot be converted to 'Integer' because
'Integer' is not a delegate type.

i have made some study on this .
1.) first we have to create a delegate object on the callback function
then
2.) we have to put the correct signature and bla.. bla
i have tried many things but it seems doesn't help me
if any body can help me please provide me the code , its urgent

TIA
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top