Make Images blink in user form

TheNoocH

Well-known Member
Joined
Oct 6, 2004
Messages
3,482
I have a bunch of images on my user form...
my goal is to have them look like they are blinking...

i tried something like this

Code:
For i = 1 To 3    ' Loop 3 times.
         For Each ctl In Main.Controls
           If TypeOf ctl Is MSForms.Image Then ctl.Visible = True
         Next ctl
       Beep
          For Each ctl In Main.Controls
           If TypeOf ctl Is MSForms.Image Then ctl.Visible = False
         Next ctl
Next i

i also tried using application.wait...but that didn't work either...the result of this is that all images are not shown (which is the default state) and i only hear one beep....if i put a break toggle on the line that shows the beep everything appears to work properly....but i guess i need to add something to this to slow down the processing...any help would be great...
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.

erik.van.geit

MrExcel MVP
Joined
Feb 1, 2003
Messages
17,832
Hi,

try this
Code:
For i = 1 To 6    ' Loop 3 times * 2
    For Each ctl In Main.Controls
    If TypeOf ctl Is MSForms.Image Then ctl.Visible = Not ctl.Visible
    Next ctl
    Me.Repaint
Next i
(didn't test) but quite sure repaint is what you need
after repaint you might insert a "sleep"line
Code:
  Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long) 
   
  '1000 milliseconds = 1 second 
  Sub Example() 
       'about 1/3 second 
       Sleep CLng(333) 
       '1/4 second 
       Sleep CLng(250) 
       '1/2 second 
       Sleep CLng(500) 
       '10 seconds 
       Sleep CLng(10000) 
  End Sub
kind regards,
Erik
 

TheNoocH

Well-known Member
Joined
Oct 6, 2004
Messages
3,482
Erik,
thanks for the response...
i added the sleep line but needed to change it to a public declare and everythign seems to work as intended...
thanks...
 

Forum statistics

Threads
1,141,599
Messages
5,707,311
Members
421,502
Latest member
PULBAG

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
Top