|
-
Dec 29th, 2002, 10:46 PM
#1
Thread Starter
Hyperactive Member
Event/RaiseEvent Question
Can anyone tell me what the major difference is between creating a Event -vs- a Sub? I'm kinda confused on custom events and when to use them?
-
Dec 29th, 2002, 11:20 PM
#2
PowerPoster
Events are used when objects need to notify a client that something of importance is happening. For instance, with a car object, you would want to raise an event when the car is overheating, thus you would create a 'Overheating' event, and raise this when appropriate.
Subs (methods in oop terms) are routines that perform some type of action (behavior) and can either return a value or not. For instance, the car object would have a TurnLeft() method that would handle the action associated with the car turning left.
-
Dec 29th, 2002, 11:31 PM
#3
I think the biggest difference is who initiates them. An event is initiated by the object itself whereas a method (sub) is initiated outside of the object.
Using the car example the car is the one that calls the overheating event, where as another object is the one that would call the FillGas method.
-
Dec 29th, 2002, 11:45 PM
#4
-
Dec 30th, 2002, 12:06 PM
#5
Thread Starter
Hyperactive Member
Hmm, Ok thanks, still a bit of confusion but I'll figure it out
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|