How to use Timer??

pip187
03-04-2002, 03:29 AM
How do I use the timer to make a pause in an event?

I have put a timer on my form, and assigned an interval of 10000.

I want to use the timer in my code, so when I click cmdChange, the code is executed up to a certain point, and then there is a 10 second pause before the rest of the code is executed.

eg.
Private Sub cmdChange_Click()
frmTest.print "Please wait 10 seconds"
(10 second pause required)
frmTest.print "thanks for waiting"
End Sub

Thanks

Phil.

Banjo
03-04-2002, 03:59 AM
You need either a DoEvents loop:
Do Until bTimerDone
DoEvents
Loop
Where you set the module level variable bTimerDone to true in the timers event.
Or you can call the second half of the code directly from the timers events.
I personally prefer the first method.

Anis
03-04-2002, 06:13 AM
Use the following function...


Sub Wait(ByVal s As Integer)
Dim t As Double
t = Now() + s / 86400#
While t > Now()
DoEvents
Wend
End Sub


If you want a delay of one second..


wait(1)


:)

ChiefRedBull
03-04-2002, 10:35 AM
My personal favourite - the Sleep API.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum