Forms, controls, and user-defined objects are examples of event senders. Event SendersĪny object capable of raising an event is an event sender, also known as an event source. For example, a derived class cannot raise events inherited from a base class. In Visual Basic, you raise events with the RaiseEvent statement, as in the following example: RaiseEvent AnEvent(EventNumber)Įvents must be raised within the scope of the class, module, or structure where they are declared. The act of broadcasting the message is called raising the event. You declare events within classes, structures, modules, and interfaces using the Event keyword, as in the following example: Event AnEvent(ByVal EventNumber As Integer)Īn event is like a message announcing that something important has occurred. This section describes the terms and concepts used with events in Visual Basic. If a user cancels the sort, your application can send a cancel event instructing the sort process to stop. Say, for example, that your application performs a sort task separately from the main application. Events also allow separate tasks to communicate. For example, when a user clicks a control on a form, the form can raise a Click event and call a procedure that handles the event. While you might visualize a Visual Studio project as a series of procedures that execute in a sequence, in reality, most programs are event driven-meaning the flow of execution is determined by external occurrences called events.Īn event is a signal that informs an application that something important has occurred.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |