Resetting a timer in VB6


Closed Thread
Results 1 to 12 of 12

Hybrid View

  1. #1
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    Thanks guys, but neither of these approaches will work. Stopping & resetting the interval is
    a no go, and a sub or proceedure that blocks button clicks isn't an option.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  2. #2
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,612


    Did you find this post helpful? Yes | No

    Default

    Hi Bruce,
    Try disabling the Timer then set the interval to 0 and then set it back to whatever interval you want before enabling it again.

    From this page on MSDN:
    The Timer control's Enabled property determines whether the control responds to the passage of time. Set Enabled to False to turn a Timer control off, and to True to turn it on. When a Timer control is enabled, its countdown always starts from the value of its Interval property setting
    So if you first set the interval to 0 and then reset it to whatever it should do what you want, right?

    /Henrik.

  3. #3
    Join Date
    Mar 2005
    Location
    Iowa, USA
    Posts
    216


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by HenrikOlsson View Post
    Hi Bruce,
    Try disabling the Timer then set the interval to 0 and then set it back to whatever interval you want before enabling it again.

    From this page on MSDN:


    So if you first set the interval to 0 and then reset it to whatever it should do what you want, right?

    /Henrik.
    This method seems to work for me. Here's a quick test I used to verify. Set timer1 interval to 3000
    Code:
    Private Sub Command1_Click()
    Timer1.Enabled = True
    End Sub
    
    Private Sub Command2_Click()
    Label1.Caption = ""
    End Sub
    
    Private Sub Command3_Click()
    Timer1.Enabled = False
    Timer1.Interval = 0
    Timer1.Interval = 3000
    End Sub
    
    Private Sub Timer1_Timer()
    Label1.Caption = "DONE"
    End Sub
    Good call Henrik!
    Wisdom is knowing what path to take next... Integrity is taking it.
    Ryan Miller

  4. #4
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    Woohoo...;o}

    Thanks guys. That did the trick.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  5. #5
    Join Date
    Dec 2013
    Posts
    1


    Did you find this post helpful? Yes | No

    Default Re: Resetting a timer in VB6


    • Private Sub Command1_Click() Timer1.Enabled = True End Sub Private Sub Command2_Click() Label1.Caption = "" End Sub Private Sub Command3_Click() Timer1.Enabled = False Timer1.Interval = 0 Timer1.Interval = 3000 End Sub Private Sub Timer1_Timer() Label1.Caption = "DONE" End Sub
      Good call Henrik!



      please pals were do i insert this code. is it the timer or the button use in starting the timre or the progress bar please help


Similar Threads

  1. Elapsed Timer Demo
    By Darrel Taylor in forum Code Examples
    Replies: 111
    Last Post: - 29th October 2012, 17:39
  2. High Resolution Timer & Speed Calculator
    By WOZZY-2010 in forum Code Examples
    Replies: 4
    Last Post: - 7th February 2010, 16:45
  3. Timer + rc5
    By naga in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 19th November 2009, 07:56
  4. Timer interrupt frequency
    By Samoele in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 17th January 2009, 23:49
  5. timer interupt help 16f73
    By EDWARD in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 3rd July 2005, 08:41

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

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