Results 1 to 5 of 5

Thread: [RESOLVED] Beginner's question on sleep function -- please help!

  1. #1

    Thread Starter
    New Member
    Join Date
    Dec 2014
    Posts
    7

    Resolved [RESOLVED] Beginner's question on sleep function -- please help!

    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.

  2. #2
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,480

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

    call Shape1.Refresh after changing it

    Welcome to the forums
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  3. #3

    Thread Starter
    New Member
    Join Date
    Dec 2014
    Posts
    7

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

    Thank you, LaVolpe

    Can you write it out for me?

    I'm really clueless...

  4. #4

    Thread Starter
    New Member
    Join Date
    Dec 2014
    Posts
    7

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

    Got it!!

    Thank you, thank you...

  5. #5
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    7,451

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

    Ms....also you can 'thank' the Fox (LaVolpe) if you click on 'rate this post', and do a favorable 'thanks'. :-)
    AND, if you wouldn't mind, mark this Thread as RESOLVED (Under Thread Tools).
    Gracias.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width