Results 1 to 5 of 5

Thread: Event/RaiseEvent Question

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2002
    Posts
    382

    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?

  2. #2
    PowerPoster Lethal's Avatar
    Join Date
    Oct 2000
    Location
    Ohio
    Posts
    2,496
    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.

  3. #3
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    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.

  4. #4
    PowerPoster Lethal's Avatar
    Join Date
    Oct 2000
    Location
    Ohio
    Posts
    2,496
    Well said...

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2002
    Posts
    382
    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
  •  



Click Here to Expand Forum to Full Width