Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Simple Timing Question

Posted on 2006-11-24
2
Medium Priority
?
167 Views
Last Modified: 2010-04-30
I  have a short procedure that needs to run every x seconds, where x ranges anywhere from 1 to 100,000.  The logic is something like:

*** pseudo code ***
When  TimeSinceLastRun reaches x seconds
    procedure()
    TimeSinceLastRun = 0
Start again
*** end *****


The simple idea is to run the procedure every x seconds.  I just don't know how to code it.

I noticed in VG an object called a Timer, but I don't know how it works.

As always, any light shed on this will be appreciated and recognized with points.
0
Comment
Question by:Danimal
2 Comments
 
LVL 1

Author Comment

by:Danimal
ID: 18010499
^^^correction, in VB, not VG, I found the Timer object.
0
 
LVL 76

Accepted Solution

by:
GrahamSkan earned 140 total points
ID: 18010646
Put a timer control on your form and add some code like this


Sub Form_Load()
Dim s as integer
s = 3 'seconds

Timer1.Interval = s*1000 'timer interval is in millisecond units
Timer1.Enabled = True
End Sub

Sub Timer1_Timer()
      procedure()
End Sub
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question