I add an event handler in my code for a user control depending on the specific operation that is requested:
AddHandler myEvent, Addressof Handle_MyEvent
When the control is disposed of, I want to remove the event handler only if it was added in the first place using:
If "the handler exists" then
RemoveHandler MyEvent, Addressof Handle_MyEvent
end if
However, I cannot find what I need to put in the "the handler exists" to check if it was actually added. I found one idea but it doesn't work:
If MyEventEvent IsNot Nothing then
It says that the MyEventEvent is private and cannot be used in this context. Any ideas on how I can do what I want?
AddHandler myEvent, Addressof Handle_MyEvent
When the control is disposed of, I want to remove the event handler only if it was added in the first place using:
If "the handler exists" then
RemoveHandler MyEvent, Addressof Handle_MyEvent
end if
However, I cannot find what I need to put in the "the handler exists" to check if it was actually added. I found one idea but it doesn't work:
If MyEventEvent IsNot Nothing then
It says that the MyEventEvent is private and cannot be used in this context. Any ideas on how I can do what I want?