Hi David,
 
Sure, there's no problem in having a single handler handle more than one
type of event; in real life things never happen "at the same time"; there's
always one which happens first, and the others will wait (that's true even
if you had separate event handlers).
 
The only restriction is that the parameter list must be the same for the two
types of events, and they require the same type of handler (either a sub or
a function).
 
It should be obvious, but you cannot have an event which requires a sub with
one parameter, and a second which requires a function with two parameters,
be handled by the same routine.
 
You've also got the question: can you tell which type of event just called
the handler?  Often you cannot, and you'll need separate routines just for
that reason.
 
hth,
 
Chip
 


  _____  

From: David [mailto:[email protected]] 
Sent: Wednesday, June 13, 2012 10:24 AM
To: [email protected]
Subject: Connecting to multiple events?


Something crossed my mind today. A bit of a techie question.
 
If I, in a script connect to multiple events, but want the same sub or
function to be executed when any of the events take place. Kind of:
 
ConnectEvent ObjectName, "Event1", "happening"
ConnectEvent ObjectName, "Event2", "happening"
 
Function Happening()
    Speak "something has happened."
End Function 'Happening.
 
Long as either of the events 1 or 2 takes place at different times, I guess
the above code would work. (sure, with real names, of course.) But what if
the two events take place at the same time? Is there any "life-line" that
secures that events don't fire simultaneously? I guess not. So in a case
like above, will I actually have to make two different eventHandling
functions, with the exact same content (good thing we have copy and paste,
smile)? Or, is there a safe way of handling a situation like this, with one
"common" EventHandler?
 
Thanks for any input.
 

Reply via email to