473,394 Members | 1,843 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

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

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?

Sep 16 '07 #1
2 1962
>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

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Sep 16 '07 #2
DOH! Couldn't see the wood for the trees!

Thanks

"Mattias Sjögren" <ma********************@mvps.orgwrote in message
news:uz****************@TK2MSFTNGP04.phx.gbl...
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

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Sep 16 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: vishakha.ganjoo | last post by:
' C Sharp function - Start ' private void id_ok_Click(object sender, EventArgs e) '{ ' try ' { ' _job = new OsaScanJob((OsaSessionState)Session); ' _job.Create(); ' _job.Completed += new...
4
by: yoramo | last post by:
hello can I pass a static method as a parameter to a method? if the answer is yes how do I do that ? how do I call the method ? yoramo.
0
by: Cordell Lawrence | last post by:
Okay guys, We are wondering if this is a bug in Framework 2.0.40607 and looking for some clarification on the issue. Take a look at the folowing code. public delegate bool BoundryTest(int...
12
by: ritchiebuckley | last post by:
I've been doing asp.net for so long now that I have forgotten about windows form programming so excuse this (seemingly) basic question. I have a form A which then opens up form B. I do stuff on...
1
by: Ajay Pal Singh | last post by:
Hi, I am making an windows service similar to windows task schedular. The service would invoke the methods of some assemblies at some predefined schedules. (windows service read the...
15
by: Patrick.O.Ige | last post by:
Hi All i'm getting error with my TreeView Menu(I want to have a button with ExpandALL and CollapseALL):- Error:- 'AddressOf' operand must be the name of a method; no parentheses are needed. I...
5
by: Simon Harris | last post by:
Hi All, I am trying to call a method in a web form, from an event fired in a user control. My user control displays a map, which has a link button to enlarge/shrink the map. When the user...
6
by: Dom | last post by:
I'm teaching myself about delegates and the Invoke method, and I have a few newbie questions for the gurus out there: Here are some CSharp statements: 1. public delegate void MyDelegate (int k,...
5
by: puzzlecracker | last post by:
I've just discovered DynamicInvoke methods while reading Jon's threading article. And my question is how it's different from a regular invoke method? In this method: /// <summary> ///...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.