Results 1 to 5 of 5

Thread: Timers..

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jun 2012
    Posts
    75

    Timers..

    How Would You Write This Code:

    Code:
                Try
                    Dim cont As Timer
                    For Each cont In Form1.Controls 'maybe issue..
                        If (TypeOf cont Is Timer) Then
                            If cont.Enabled = True Then
                                DR1.Text += cont.Interval
                            End If
                        End If
                    Next
                Catch
                    MsgBox(ErrorToString)
                End Try
    What it's supposed to do:

    Act As A Shortcut To Let Me Know Of All Active Timers On Form1
    Without Having To Write Each Out Individually.

    Thanks

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

    Re: Timers..

    Timer is not a control, found a couple examples here, so maybe try,...
    Code:
    Dim total As Integer
    
    For Each c As Object In Me.components.Components
        If TypeOf c Is Timer Then
            total += DirectCast(c, Timer).Interval
        End If
    Next
    
    TextBox1.Text = total.ToString

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Jun 2012
    Posts
    75

    Re: Timers..

    Thanks edge!

  4. #4
    Powered By Medtronic dbasnett's Avatar
    Join Date
    Dec 2007
    Location
    Jefferson City, MO
    Posts
    9,897

    Re: Timers..

    How many forms timers do you have?
    My First Computer -- Documentation Link (RT?M) -- Using the Debugger -- Prime Number Sieve
    Counting Bits -- Subnet Calculator -- UI Guidelines -- >> SerialPort Answer <<

    "Those who use Application.DoEvents have no idea what it does and those who know what it does never use it." John Wein

  5. #5
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,104

    Re: Timers..

    This shouldn't be an issue. If you have more than two timers you are doing something wrong.
    My usual boring signature: Nothing

Tags for this Thread

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