Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter
 
 
 
MSDN Visual Basic Community
 
 
 
 
TitleMake a timer wait a long time between events
Keywordstimer, long timer, wait
CategoriesControls
 
Store the next event time in a variable. Use a timer to check periodically to see if the time has arrived.
 
Private Sub tmrTrigger_Timer()
    ' See if it time for the event.
    If Timer >= NextEventTime Then
        ' Process the event.
        lblEventTime.Caption = Format$(DateAdd("s", _
            INTERVAL_SECONDS, Time))

        ' Set the new event time.
        NextEventTime = NextEventTime + INTERVAL_SECONDS
    End If

    ' Set the timer's interval.
    If NextEventTime - Timer < 60 Then
        tmrTrigger.Interval = (NextEventTime - Timer) * 1000
    Else
        tmrTrigger.Interval = 60000
    End If
End Sub
 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated