Results 1 to 4 of 4

Thread: timers off

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Feb 2008
    Posts
    105

    timers off

    is there an "ALL timers enabled=false" feature?

  2. #2
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: timers off

    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?

  3. #3
    VB For Fun Edgemeal's Avatar
    Join Date
    Sep 2006
    Location
    WindowFromPoint
    Posts
    4,255

    Re: timers off

    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

  4. #4
    Only Slightly Obsessive jemidiah's Avatar
    Join Date
    Apr 2002
    Posts
    2,431

    Re: timers off

    You can modify Edgemeal's code to optionally shut off all timers on all forms.

    vb Code:
    1. Public Sub StopTimers(Optional frm As Form = Nothing) 'if no argument supplied, frm Is Nothing
    2.  
    3.     Dim ctl As Object
    4.  
    5.     'Mode 1: shut down all timers
    6.     If frm Is Nothing Then
    7.         For Each frm In Forms
    8.             StopTimers frm
    9.         Next
    10.        
    11.         Exit Sub
    12.     End If
    13.  
    14.     'Mode 2: shut down this form's timers
    15.     For Each ctl In frm
    16.        If TypeOf ctl Is Timer Then
    17.           ctl.Enabled = False
    18.         End If
    19.     Next ctl
    20.  
    21. End Sub

    Stop all Timers on Form1:
    StopTimers Form1
    Stop all timers everywhere:
    StopTimers 'no argument
    The time you enjoy wasting is not wasted time.
    Bertrand Russell

    <- Remember to rate posts you find helpful.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width