Is There any function to sleep one or two second?

Using the timer seems the only way

pseudo code

Init Timer

Do something

Enable Timer
.
.
.
Timer Tick - continue doing stuff after the pause.

It would be nice to be able to pause it at the line then after the pause continue. Using the timer breaks up the code.

regards, Rick
 
Upvote 0
Pausing the main thread will make your app unresponsive. Pausing for more than 5 seconds will crash your app with: "Application Not Responding" dialog.

You can implement a "busy loop" method:
Code: Copy
Sub WaitFor(Milliseconds As Int)
 Dim s As Long
 s = DateTime.Now
 Do While DateTime.Now < s + Milliseconds

 Loop
End Sub
 
Upvote 0
Thanks Erel.

I've tested that and it works perfect.

Code: Copy
Dim starttime, endtime As Long
   Msgbox("Start waiting", "")
   starttime = DateTime.Now
   u.WaitFor(2000) '2 seconds
   endtime = DateTime.Now
   Msgbox(((endtime-starttime)/1000) & " seconds", "")

There is a 2 second delay before the 2nd msgbox pops up and I can't click any of my other views on the screen.

regards, Ricky
 
Last edited:
Upvote 0

Similar Threads

Back
Top