Method ... does not have the same signature as delegate ...

B

Brian J

Please can anyone help a delegate newbie.
I am 'upgrading' some VB6 code ...

'UPGRADE_WARNING: Add a delegate for AddressOf MidiIN_Proc
midiError = midiInOpen(hMidiIN, mMPU401IN, AddressOf
MidiIN_Proc, 0, CALLBACK_FUNCTION)

and am getting the error ...

Method 'Public Sub MidiIN_Proc(hmIN As Integer, wMsg As Integer, dwInstance
As Integer, dwParam1 As Integer, dwParam2 As Integer)' does not have the
same signature as delegate 'Delegate Function MidiIN_Proc_Delegate(hmIN As
Integer, wMsg As Integer, dwInstance As Integer, dwParam1 As Integer,
dwParam2 As Integer) As Integer'.

definitions ...

Delegate Function MidiIN_Proc_Delegate( _
ByVal hmIN As Integer, ByVal wMsg As Integer, _
ByVal dwInstance As Integer, ByVal dwParam1 As Integer, _
ByVal dwParam2 As Integer) As Integer

Declare Function midiInOpen Lib "winmm.dll" ( _
ByRef lphMidiIn As Integer, ByVal uDeviceID As Integer, _
ByVal dwCallback As MidiIN_Proc_Delegate, ByVal dwInstance As
Integer, _
ByVal dwFlags As Integer) As Integer

Public Sub MidiIN_Proc(ByVal hmIN As Integer, ByVal wMsg As Integer, _
ByVal dwInstance As Integer, ByVal dwParam1 As Integer, _
ByVal dwParam2 As Integer)

I have read a lot of articles that seem to have confused the issue.
Can anyone point to where I am going wrong please?
 
M

Mattias Sjögren

I have read a lot of articles that seem to have confused the issue.
Can anyone point to where I am going wrong please?

The delegate represents a Function returning an Integer, but the
actual procedure is a Sub with no return value. MidiIN_Proc has the
correct signature (except that some parameters should be IntPtrs
rather than Integers), so it's the delegate declaration you should
change.


Mattias
 

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