Solved

Simple Timing Question

Posted on 2006-11-24
2
161 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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…
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…

742 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