Results 1 to 3 of 3

Thread: Withevents....what do they mean?

  1. #1

    Thread Starter
    Hyperactive Member gmatteson's Avatar
    Join Date
    Feb 2002
    Location
    Rhode Island, USA
    Posts
    293

    Withevents....what do they mean?

    Dim WithEvents StockInfoEventHandler As StockInfo

    What does the WithEvents mean? Can someone explain what this does and what it is used for and why? Thank you.

  2. #2
    Frenzied Member
    Join Date
    Oct 2002
    Location
    Gammapolis
    Posts
    1,474
    From MSDN:
    The WithEvents keyword allows you to create class or module-level object variables that can be used with the Handles clause in event handlers.
    So when you declare something WithEvents then you can handle events with it in this way
    VB Code:
    1. Sub myevent(event arguments goes here) Handles myobject.Event
    2.  
    3. some code here
    4.  
    5. End Sub
    'Heading for the automatic overload'
    Marillion, Brave, The Great Escape, 1994

    'How will WE stand the FIRE TOMORROW?'
    Eloy, Silent Cries and Mighty Echoes, The Vision - Burning, 1979

  3. #3
    Addicted Member
    Join Date
    Feb 2002
    Location
    closed
    Posts
    196
    Yeah, it basically exposes all the events of one object to the caller so you can catch and deal with those events that are raised.

    the withevents keyword has a slight performance hit in that ALL events will exposed/fired whether you want to catch them or not...well it was that way at least in VB6

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