I’ve been trying to create a simulator – it requires as close to real-time operation as possible. I have a couple of questions about timers.
- How do I activate a timer for more then 60 seconds?
- Will DoEvents be good enough to make sure all the other proceduresare working? There could be more then one “delayed” record in one time.Help will be highly appreciated!
To create a timer that lasts 60 seconds, in the Timer_Timer event, keep a counter of how many 60 second intervals have taken place. Once the counter reaches 5, for instance, do your regular code. That would let you time a five minute interval, for instance. Make sure you reset the counter when you reach the intended count.
DoEvents tells VB to process the event queue. Make sure you have them in any long-running loops. If you’re using a timer, VB considers that code idle and can process other code at the same time. DoEvents is useful if you are using a busy loop or are processing lots of records in a loop. A DoEvents in between will let the interface refresh occasionally. Supposedly, VB 4.0 and Windows 95 don’t need the DoEvents; however, I have found that without them, the user interface does not refresh at all in some cases.