Demonstration of creating an event handler and attaching to an event

Public Class Form1
    '  MCTS70-536-1-3
    '  Registering and handling Events
    Private t As Timer
    Private p As ProgressBar
    Private Sub t_Tick(ByVal sender As Object, ByVal e As EventArgs)
        p.Value += 1
        If p.Value = 100 Then
            p.Value = 1
        End If
    End Sub
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        '  --- Create a progressbar and add it to the form
        p = New ProgressBar
        p.Location = New Point(20, 20)
        '  //
        ' --- Programmaticaly create a timer
        t = New Timer
        t.Interval = 100
        '  --- Attach the tick event
        AddHandler t.Tick, AddressOf t_Tick
        '  --- Start the timer
    End Sub