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

  • Thread starter Thread starter Patrick Dugan
  • Start date Start date
P

Patrick Dugan

I am *trying* to convert a VB6 program to vb.net. One error I am getting
that I cannot figure out is:

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

This is the offending line where the error is located:

res = UUIRTSetReceiveCallback(hDrvHandle, AddressOf IRReceiveCallback, Me)

This is the sub routine it is calling from the "AddressOf"

Public Sub IRReceiveCallback(ByVal IRCode As Integer, ByVal userData As
Integer)
Call PostMessage(frmMain.NewPtr, WM_GOT_RECEIVE, 0, IRCode)
End Sub


How can I modify this to use a "delegate"?
 
The AddressOf will only take a name without parameters.. Example:

Dim t As New Ststem.Threading.Thread(AddressOf DoSomething) ' ok

Dim t As New Ststem.Threading.Thread(AddressOf DoSomething(i As Integer)) '
error

All you need to do is create your delegate:

Delegate sub SomeName (IRCode As Integer, userData As Integer)

Then you can create your sub. Example

Private Sub SomeSub (iNumber As Integer, iNumber2 As SomeName) 'Use Delegate
....
End Sub
 
Thanks! The example that was mentioned previously wasn't much help. I
appreciate the assistance!
 

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

Back
Top