is there an "ALL timers enabled=false" feature?
Printable View
is there an "ALL timers enabled=false" feature?
No.. you can either write out several .Enabled = False statements, or use a loop as shown in the FAQ articleHow should I close my form/program/class?
You could make a function to do that, something like,
' i.e. Stop all Timers on Form1Code:Public Sub StopTimers(frm As Form)
Dim ctl As Object
For Each ctl In frm
If TypeOf ctl Is Timer Then
ctl.Enabled = False
End If
Next ctl
End Sub
StopTimers Form1
You can modify Edgemeal's code to optionally shut off all timers on all forms.
vb Code:
Public Sub StopTimers(Optional frm As Form = Nothing) 'if no argument supplied, frm Is Nothing Dim ctl As Object 'Mode 1: shut down all timers If frm Is Nothing Then For Each frm In Forms StopTimers frm Next Exit Sub End If 'Mode 2: shut down this form's timers For Each ctl In frm If TypeOf ctl Is Timer Then ctl.Enabled = False End If Next ctl End Sub
Stop all Timers on Form1:
StopTimers Form1
Stop all timers everywhere:
StopTimers 'no argument