alternate pictures while userform is running?

lpking2005

Board Regular
Joined
Mar 21, 2011
Messages
140
morning all.. or maybe afternoon. ;)

I currently have 2 pictures of the same light, one turned off and one turned on.

I have placed the pictures on top of each other, im finding it hard to get it to change between the two to give it an animated .gif image effect with the light turning on and off repeatedly.

Does anyone know if this is acheivable?

at the moment all im playing with is setting each pictures .visible attribute to true or false every now and again, but not sure how to get it to loop until the user closes the userform. :confused:

Any help would be great!
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
Here’s my take:

Need a form with
Pictures Dark and Light (make one visible the other not)
and a checkbox: CheckBox1

This will keep going until the CheckBox is checked

DO NOT CLOSE THE FORM UNTIL THIS HAS STOPPED

‘----------------------------------
‘----------------------------------
‘----------------------------------
Option Explicit
‘----------------------------------
‘----------------------------------
‘----------------------------------
Public Sub mytimer()
Dim PauseTime, Start
PauseTime = 2
Start = Timer
Do While Timer < Start + PauseTime
DoEvents
Loop
Me.Dark.Visible = Not Me.Dark.Visible
Me.Light.Visible = Not Me.Light.Visible
End Sub
‘----------------------------------
‘----------------------------------
‘----------------------------------
Private Sub UserForm_Activate()
Do While Me.CheckBox1.Value = False
mytimer
Loop
End Sub
‘----------------------------------
‘----------------------------------
‘----------------------------------
 
Upvote 0
this is brilliant!! many thanks....:)

but one problem is that when its running, it hides both pictures before reopening the next picture causing a blank space where the pictures are located.

There should always be one of the images visible.
 
Upvote 0
Oh boy! Try putting..

Application.ScreenUpdating = False
'
'
'
'
Application.ScreenUpdating = True

around the code that changes the visibility
 
Upvote 0
Why change the visibility of both? If the image on top is visible, then surely the lower image will be hidden anyway. So have the 'on' image below the 'off' image and just switch between 'off' = visible and 'off' = invisible.

Mind you, I've not actually tried this myself...
 
Upvote 0

Forum statistics

Threads
1,203,483
Messages
6,055,669
Members
444,806
Latest member
tofanexcel

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