H
hartley_aaron
Hi,
I was trying to store the address of the my current handler for a
particular event so as to simplify using AddHandler and RemoveHandler
throughout my code. However, I cannot seem to get any kind of variable
to except the data. When I tried a Long I got the message "'AddressOf'
expression cannot be converted to 'Long' because 'Long' is not a
delegate type." I tried other datatypes as well but was not able to
find anything that worked. Here is a very simply example of what I am
trying to do:
Dim CurrentHandler as Long
....
RemoveHandler MyObject.SomethingHappens, CurrentHandler
CurrentHandler = AddressOf DoThis
AddHandler MyObject.SomethingHappens, CurrentHandler
....
RemoveHandler MyObject.SomethingHappens, CurrentHandler
CurrentHandler = AddressOf DoThat
AddHandler MyObject.SomethingHappens, CurrentHandler
....
RemoveHandler MyObject.SomethingHappens, CurrentHandler
CurrentHandler = AddressOf DoSomethingElse
AddHandler MyObject.SomethingHappens, CurrentHandler
I was trying to store the address of the my current handler for a
particular event so as to simplify using AddHandler and RemoveHandler
throughout my code. However, I cannot seem to get any kind of variable
to except the data. When I tried a Long I got the message "'AddressOf'
expression cannot be converted to 'Long' because 'Long' is not a
delegate type." I tried other datatypes as well but was not able to
find anything that worked. Here is a very simply example of what I am
trying to do:
Dim CurrentHandler as Long
....
RemoveHandler MyObject.SomethingHappens, CurrentHandler
CurrentHandler = AddressOf DoThis
AddHandler MyObject.SomethingHappens, CurrentHandler
....
RemoveHandler MyObject.SomethingHappens, CurrentHandler
CurrentHandler = AddressOf DoThat
AddHandler MyObject.SomethingHappens, CurrentHandler
....
RemoveHandler MyObject.SomethingHappens, CurrentHandler
CurrentHandler = AddressOf DoSomethingElse
AddHandler MyObject.SomethingHappens, CurrentHandler