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.
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 ...