Dim dblClock As Double
dblClock = Timer
While abs(Timer - dblClock) < 3 ' Wait 3 seconds
DoEvents
Wend
This will stop it running all day if it just happens to execue at midnight.
Purists would probably want to use Now() instead of Timer, but I think it's not worth the trouble for the odd time the code may execute at midnight.
Now I'm sure somebody will say 'Yes, but the Timer uses less cpu time'. I don't buy that. The above code may SEEM to use more cpu time while the loop is running, but it should give up any time slices needed by other apps if required - so I don't think it matters. Must try it sometime with a test app and see if it has any real effect.
Last edited by BrianHawley; Oct 21st, 2001 at 04:12 AM.
Brian
(Fighting with the RightToLeft bugs in VS 2005)