ID: 288
Viewed: 3265
Added: Jul 26, 2002
Version:
Snippet uploaded by: snippet
Written By: unknown
Demo: Sorry, no demo
Thank you for your vote. Please wait...
It appears you already voted for this snippet
It appears your vote value was empty
Using the Sleep API call pauses your entire application. It pauses EVERYTHING in your entire application. This means that if you have something like this:
code:-------------------------------------------
Label1.Visible = True
Sleep 1000
Label1.Forecolor = RGB(255,0,128)
Sleep 1000
-------------------------------------------------
You'd think Label1 would appear, wait one second, and then turn purple, right? Wrong. All you'd see is nothing for a delay of two seconds, and then LAbel1 would pop up, both visible and purple. Y'see, Label1 would become visible as far as the code is concerened, but not on the screen. The Sleep call jumps right in there and pauses everything without waiting for a screen refresh. That's what the DoEvents is for. It doesn't make the Sleep call any more accurate, but it makes the results visible. Thus:
code:-------------------------------------------
Label1.Visible = True
Sleep 1000
Label1.Forecolor = RGB(255,0,128)
Sleep 1000
-------------------------------------------------
You'd think Label1 would appear, wait one second, and then turn purple, right? Wrong. All you'd see is nothing for a delay of two seconds, and then LAbel1 would pop up, both visible and purple. Y'see, Label1 would become visible as far as the code is concerened, but not on the screen. The Sleep call jumps right in there and pauses everything without waiting for a screen refresh. That's what the DoEvents is for. It doesn't make the Sleep call any more accurate, but it makes the results visible. Thus:
Highlight all by clicking in box
<!---Declaration--->
none
Highlight All
<!---Code--->
'code:---------------------------------------
Label1.Visible = True
DoEvents
Sleep 1000
Label1.Forecolor = RGB(255,0,128)
DoEvents
Sleep 1000
'--------------------------------------------
'This would give you the desired result, Label1 appearing, 'waiting one second, and turning purple.
;
No Comments to show
Please completely fill out the form below if you want to review this snippet. All reviews are subject to validation.
Adding your comment. Please wait...
Thanks for adding your comment!. After further review it will be added.
There was a problem adding your comment. Please try again.
Please complete all the fields in the form before sending.