-
In my program there is a need to do a delay.
There are few subs that need the delay like:
Code:
Sub Kick(Index as integer)
send index, "You prepare to kick"
'Here supposed to be a SmartDelay of 3 seconds
send index, "You kick him"
End Sub
Sub Punch(Index as integer)
send index, "You prepare to punch"
'Here supposed to be a SmartDelay of 5 seconds
send index, "You punch him"
End Sub
I need the code to delay in that places.
It is important that the code won't stop because of the delay (No do-loop with doevents delays).
What should I do?
-
A small little nap?
Code:
Private Declare Sub Sleep Lib "kernel32" _
(ByVal dwMilliseconds As Long)
Call Sleep(1000) '1 second
-
=(
Thanks but no.
Sleep freezes the program, the program should be able to call the Punch sub even if it still in a delay of a kick (There will be two delays in this case.
Do-DoEvents-Loop_Until code is not good only because if you for example starting to Punch while still not finishing kicking then it will go to the other Do-Loop and the kick won't be finished before the punch.