VB Code:
Dim WithEvents TimerEvent As Timer
Dim timr As New Timer()
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
timr.Interval = 2000
timr.Enabled = True
End Sub
Private Sub FireTimer(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TimerEvent.Tick
MsgBox("Hey there")
End Sub
Private Sub StopTimer()
timr.Enabled = False
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
AddHandler timr.Tick, AddressOf FireTimer
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
timr.Enabled = False
End Sub