Reputation: 97
I'm fairly new to programming and I was told that I should be passing things using ByRef and ByVal, but when I do so, I get an error saying:
Error 3 Method 'Private Sub Activate_Click(ByRef intIDToChange As Integer, sender As Object, e As System.EventArgs)'
cannot handle event 'Public Event Click(sender As Object, e As System.EventArgs)' because they do not have a compatible signature.
F:\Dropbox\Gooby Backup\School Work\Computing\Unit 4\Room Booking Client\WindowsApplication1\ActivateDeactivate\Activate Deactivate.vb 32 129 WindowsApplication1
I start my sub with:
Private Sub Activate_Click(ByRef intIDToChange As Integer, sender As System.Object, e As System.EventArgs) Handles Activate.Click
Upvotes: 0
Views: 953
Reputation: 96
It sounds like the event handler you've declared there (Activate_Click) doesn't match the event definition for ActivateClick.
Try changing to:
Private Sub Activate_Click(ByVal intIDToChange As Integer, ....) Handles Activate.Click
ByVal sends the value of the variable via the parameter, whereas ByRef sends the variable (meaning changes made in the subroutine affect the calling routines variable).
More detailed answer here: http://social.msdn.microsoft.com/Forums/en-US/vbgeneral/thread/07b9d3b9-5658-49ed-9218-005564e8209e/
Upvotes: 0
Reputation: 9178
You have to define your method as
Private Sub Activate_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Activate.Click
because the button click event takes only two arguments.
If you want to use the variable intIDToChange
, provide that as a class level variable like
private intIDToChange as Integer
and update it in Activate_Click
.
Upvotes: 0
Reputation: 125640
You can't handle Activate.Click
with your method, because you have additional Integer
parameter which is not compatible with Event signature.
Event signature
Click(sender As Object, e As System.EventArgs)
Your method
Activate_Click(ByRef intIDToChange As Integer, sender As System.Object, e As System.EventArgs)
Upvotes: 2