Timer Control

A

al

I justused this to test timer in a visio document, worked
fine.


Public Sub test_timer()

Dim PauseTime, Start, Finish, TotalTime
If (MsgBox("Press Yes to pause for 5 seconds", 4)) = vbYes
Then
PauseTime = 5 ' Set duration.
Start = Timer ' Set start time.
Do While Timer < Start + PauseTime
DoEvents ' Yield to other processes.
Loop
Finish = Timer ' Set end time.
TotalTime = Finish - Start ' Calculate total time.
MsgBox "Paused for " & TotalTime & " seconds"
Else
End
End If



End Sub
 
C

Chuck Bowling

Thanks al. I saw this example in the help files.

I was hoping to avoid using it because it seems to me that using a loop to
do your timing would incur a lot of unnecessary overhead and add to the
complexity of doing simultaneous nonthreaded events. Also, I think the Timer
Control is driven thru the hardware interrupt which would cut way down on
processing.
 
A

al

Chuck,
I agree with not wanting to do loops, unfortunately
without the embedded 'doevents' the timer can take control
and lock out everything else.
a.
 
C

Chuck Bowling

Right now I'm looking into a possible alternative. I might be able to
implement a system timer thru a Windows API call. I have some code but I
don't have any experience doing API calls from VBA so I'm treading
cautiously right now.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top