O'Reilly logo

Microsoft® Visual Basic® 2010 Developer’s Handbook by Klaus Löffelmann and Sarika Calla Purohit

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Embedding Events Dynamically with AddHandler

Event embedding using the keyword WithEvents fails when you declare the objects that provide the events at the procedure level (locally) or if they’re part of an array or collection. In such situtations, you can wire up events dynamically at runtime by using AddHandler.

Companion Content

Open the corresponding solution (.sln), which you can find in the \VB 2010 Developer Handbook\Chapter 15\Alarm02 folder.

This example expands the simple alarm clock application you saw earlier in the chapter by permitting more than just one alarm time. When you start the program, you see the screen depicted in Figure 15-8.

Figure 15-8. The modified Alarm Clock application can capture several alarm times.

Figure 15-8 shows ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required