By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,572 Members | 1,439 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,572 IT Pros & Developers. It's quick & easy.

Method does not have same signature etc...

P: n/a
I created a button dynamically and added an event hander as follows:
AddHandler newbtnPick.Click, AddressOf newbtnPick_Click

Private Sub newbtnPick_Click()

End Sub

I get an error:
Method 'Public Sub newbtnPick_Click()' does not have the same signature as
delegate 'Delegate Sub EventHandler(sender As Object, e As
System.EventArgs)'.

So of coutse I added
ByVal sender As Object, ByVal e As EventArgs

to give me
Private Sub newbtnPick_Click(ByVal sender As Object, ByVal e As EventArgs)

End Sub

In fact even this does nto work:
Private Sub newbtnPick_Click(ByVal sender As Object)

End Sub

Why do I need the second parameter? And I am curious, how does it know I
will need the sender object?

Thanx,

--
Anil Gupte
www.keeninc.net
www.icinema.com
Oct 29 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
>Why do I need the second parameter? And I am curious, how does it know I
>will need the sender object?
You need to make sure the method signature matches the delegate
signature. It doesn't matter if you're actually going to use the
parameters in your code or not.
Mattias

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

This discussion thread is closed

Replies have been disabled for this discussion.