Solved

Simple Timing Question

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Help in WHSCRIPT 9 47
Excel object stays open 19 71
Paint/Redraw window while dragging 16 68
String manipulation in Visual Basic 7 59
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…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

920 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

12 Experts available now in Live!

Get 1:1 Help Now