Solved

Simple Timing Question

Posted on 2006-11-24
2
156 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 35 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

708 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now