Vbnet-processing object events during runtime (addhandler and removehandler)

Source: Internet
Author: User
  1. Addhandler is used to process events and events at runtime.ProgramAssociated
    Removehandler is used to remove the association between events and event handlers.
    The handles keyword is used to specify the specific event it processes when defining a process.
  2. Signature:
    AddhandlerEvent, AddressofEventhandler

    Removehandler event, addressof eventhandler
  3.  Code Demo
    1 Sub Testeven TS () ' Test the event Process
    2 Dim OBJ As   New Class1 ' Associate an event handler with an event.
    3 Addhandler OBJ. ev_event, Addressof Eventhandler ' Associated events and their handling
    4 OBJ. causesomeevent () ' Events
    5 Removehandler OBJ. ev_event, Addressof Eventhandler ' Remove Association.
    6 OBJ. causesomeevent () ' Events
    7 End sub
    8
    9 Sub Eventhandler () ' Event handling process
    10 Msgbox ( " Eventhandler caught event. " )
    11 End sub
    12
    13 Public   Class Class1 ' Contains the custom class of the event.
    14 Public   Event Ev_event () ' Event statement-Custom Event Process
    15 Sub Causesomeevent () ' The process of activating an event.
    16 Raiseevent Ev_event () ' Use raiseevent statements to activate events
    17 End sub
    18 End Class
    19
    20

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.