Quantcast
Channel: VBForums - Visual Basic 6 and Earlier
Viewing all articles
Browse latest Browse all 21116

Beginner's question on sleep function -- please help!

$
0
0
Hi, I'm having a perplexing problem with a really simple piece of code.

I have a label that, when clicked, is supposed to change the color of an oval to blue, wait half a second, and then change the color of the oval to yellow.

Here's the code:

Private Sub Label1_Click()
Shape1.FillColor = vbBlue
Sleep 500
Shape1.FillColor = vbYellow
End Sub

Of course, I have also written "Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)" under "general".

However, when I click this label, what happens is that there is a delay, and then the oval turns yellow. I never see the blue at all.
Please explain what I am doing wrong.
I have had other problems of the same sort with the "sleep" function.

Viewing all articles
Browse latest Browse all 21116


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>