Add the event handle of this event and copy the following code into the event handler.
Input some invalid values and try to move the focus.
In addition, as with other methods, the event handlers can be specified with the method is executed in any instance of the class.
This might be useful for notifying several consumers when shared data changes, for example, in a service application that periodically queries a database and exposes the data through shared properties. NET expands the ability to use events by implementing dynamic event handling in addition to the declarative approach discussed earlier.
Declarative event handling is certainly the most convenient way to handle events, although as mentioned, it requires the object variable to be scoped correctly and cannot be used to dynamically turn an event handler on or off.
When dealing with inheritance, keep in mind that if a class acting as a consumer does not implement the event handlers for a particular object, classes derived from it will not be able to implement them later.
In this article, learn event handling and the major uses of delegates in VB. Dan Fox discusses mapping events to delegates, function substitution with delegates, and asychronous processing with delegates.
This article is excerpted from Chapter 4, "Object-Oriented Features," from Building Distributed Applications with VB. This material is based on the Beta2 release version of Microsoft's . This article assumes that the reader has some experience with VB, the Windows environment, event-based programming, basic HTML, and scripting.
Of course, this is exactly the model used when dealing with events.
Dynamic event handling can be very useful when you want to turn event handling on or off (called hooking and unhooking an event) at a specific time or when the object variable that you want to hook does not reside at the module or class level.