vba delay help

FUNwithOFFICE

New Member
Joined
Dec 22, 2011
Messages
3
i've been trying to make a simple blinking animation of showing and subsequently hiding an image on a userform. i used

Code:
Application.Wait Now + TimeValue("00:00:01")
and it worked great but i really need less than one second delay.

then i tried using delay like so:

Code:
Public Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

Private Sub blink()
Image1Glow.Visible = True
Sleep 500
Image2Glow.Visible = True
Sleep 500
Image3Glow.Visible = True
Sleep 500
Image4Glow.Visible = True
End Sub

when i ran it step by step with F8 function it seemed to work just fine but when i actually ran it it smushed it all together so the result was something akin to:

Code:
Sleep 500
Sleep 500
Sleep 500
Image1Glow.Visible = True
Image2Glow.Visible = True
Image3Glow.Visible = True
Image4Glow.Visible = True
what can i do to fix this?

(i'm operating excel 2007 with vista)
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
Hi there and welcome to the board.

You need to "repaint" the userform..

Try:

Code:
Private Sub blink()
    Image1Glow.Visible = True
    Sleep 500
    Me.Repaint
    Image2Glow.Visible = True
    Sleep 500
    Me.Repaint
    Image3Glow.Visible = True
    Sleep 500
    Me.Repaint
    Image4Glow.Visible = True
End Sub
 
Upvote 0
i've added pictures to the image objects and now the repaint makes it flicker so bad i can't even see the animation. i've looked up and down the net and i can't find any help in this matter...:(
 
Upvote 0
i've added pictures to the image objects and now the repaint makes it flicker so bad i can't even see the animation. i've looked up and down the net and i can't find any help in this matter...:(

Do what Andrew suggested .
 
Upvote 0

Forum statistics

Threads
1,214,952
Messages
6,122,458
Members
449,085
Latest member
ExcelError

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top