Dim allmytimers(2) As Timer
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles MyBase.Load
Dim t As New Timer
t.Tag = "mytimer1"
t.Interval = 1000
AddHandler t.Tick, AddressOf AnyTimer2_Tick
t.Start()
allmytimers(0) = t
t = New Timer
t.Tag = "mytimer2"
t.Interval = 1500
AddHandler t.Tick, AddressOf AnyTimer2_Tick
t.Start()
allmytimers(1) = t
t = New Timer
t.Interval = 400
AddHandler t.Tick, AddressOf AnyTimer3_Tick
t.Start()
allmytimers(2) = t
End Sub
Dim ix As Integer
Private Sub AnyTimer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs)
ix += 1
Me.Text = DirectCast(sender, Timer).Tag.ToString & " - " & ix.ToString
End Sub
Private Sub AnyTimer3_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs)
ix += 1
Me.Text = "timer 3 - " & ix.ToString
End Sub
Private Sub BtnStop_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles Button2.Click
For Each t As Timer In allmytimers
t.Stop()
Next
End Sub