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?
(Microsoft MVP from July 2007 to June 2017) . . . . . . . . . . Hitchhiker's Guide to Getting Help at VBForums Database Development FAQs/Tutorials (updated May 2011) (includes fixing common DB related errors, and [VB.Net] ADO.Net Tutorial, and [Classic VB] ADO tutorial /further steps) other useful DB bits: . Connection strings (alternative copy).•. MDAC/Jet/ACE downloads .•. SQL Server downloads . Classic VB FAQs (updated Oct 2010) (includes fixing common VB errors) some of my Classic VB bits: . Tutorial: How to automate Excel from VB6 (or VB5/VBA) .•. SQL 'Select' statement formatter/checker .•. Convert colour number to colour name .•. FlexGrid: fill from recordset .•. FlexGrid: AutoSize columns .•. DB Reserved Words checker .
You could make a function to do that, something like, Code: 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 ' i.e. Stop all Timers on Form1 StopTimers Form1
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
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
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
The time you enjoy wasting is not wasted time. Bertrand Russell <- Remember to rate posts you find helpful.
Forum Rules