Results 1 to 8 of 8

Thread: [RESOLVED] Timer Interval?

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2007
    Location
    Canada
    Posts
    297

    Resolved [RESOLVED] Timer Interval?

    Hey folks,

    I am looking to make a timer so that every 5 minutes it will activate a line of code, like a timer would.. But I can't get the timer to go over a certain amount of time..

    I've tried "Timer1.Interval = 300000" but that doesnt seem to work, does anyone know a way around this or a peice of code that will do the same thing?

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Timer Interval?

    The standard VB timer is only good for 65 seconds.

  3. #3
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Timer Interval?

    CVMichael post a timer submission in our CodeBank that I just went and retrieved the URL for. It might help you out.

    http://www.vbforums.com/showthread.php?t=511995

  4. #4
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,803

    Re: Timer Interval?

    wxmancanada, if your gonna use my code, then make sure you compile QPTimerThread, then open QPTimerTestSingleThread to see how the timer thread is loaded and used. (Also make sure the reference to the QPTimer is selected)

    You can remove all the code in the TimerEvent() call except the line where ContinueTimer = True

    You can put any interval you want when you start the timer.

  5. #5
    Lively Member
    Join Date
    Feb 2007
    Posts
    79

    Re: Timer Interval?

    Set the timer for 60000 (60 seconds) and use a counter:

    vb Code:
    1. Private Sub Timer1_Timer()
    2.  
    3.     Dim iMinutes As Integer
    4.     iMinutes = iMinutes + 1
    5.    
    6.     If iMinutes = 5 Then
    7.         '   5 minutes have passed, run code:
    8.        
    9.  
    10.         MsgBox "5 minutes have passed", vbInformation, "Notice:"
    11.        
    12.         iMinutes = 0    '   Reset
    13.     End If
    14.    
    15. End Sub

  6. #6
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: Timer Interval?

    Many options; here is another one:
    1. in declarations section: Private tmrEventTime As Date
    2. When ready to enable timer: tmrEventTime = DateAdd("n",5,Now())
    3. In timer event: If Now()>tmrEventTime then ' 5 minutes elapsed
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  7. #7

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2007
    Location
    Canada
    Posts
    297

    Re: Timer Interval?

    Quote Originally Posted by __Russell__
    Set the timer for 60000 (60 seconds) and use a counter:

    vb Code:
    1. Private Sub Timer1_Timer()
    2.  
    3.     Dim iMinutes As Integer
    4.     iMinutes = iMinutes + 1
    5.    
    6.     If iMinutes = 5 Then
    7.         '   5 minutes have passed, run code:
    8.        
    9.  
    10.         MsgBox "5 minutes have passed", vbInformation, "Notice:"
    11.        
    12.         iMinutes = 0    '   Reset
    13.     End If
    14.    
    15. End Sub
    That's perfect! Thank you!

  8. #8
    Lively Member
    Join Date
    Feb 2007
    Posts
    79

    Re: [RESOLVED] Timer Interval?

    Simple is best.
    Last edited by __Russell__; Mar 7th, 2008 at 11:12 AM.

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