Frame1.visible = false

vmjan02

Well-known Member
Joined
Aug 15, 2012
Messages
1,057
Office Version
  1. 365
  2. 2021
  3. 2019
  4. 2016
  5. 2013
I have a user form and it has 5 frame's, with Frame1 to Frame5 and a button name as "start".

Once the user clicks the button, all the 5 Frame's are visible = true

What I need is (not so sure) do or can we create a timer as once the user clicks the button and after 10 sec the Frame1.visible = false, then next 10 sec Frame2.visible = false, then next 10 sec Frame3.visible = false.

Any Idea.
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
Re: Frame1.visiable = false

Hi;

I am assuming the object names as: Userform1, CommandButton1, Frame1, Frame2, Frame3, Frame4 and Frame5.

If the names are diffrent, then revise the following codes according to your project.

So; in your Userform1 code module paste the following; which will make the Frames visible and start them hiding.

Code:
Private Sub CommandButton1_Click()
    For i = 1 To 5
        Me.Controls("Frame" & i).Visible = True
    Next
    Call StartTimer
End Sub

Add a new module to your project and paste the following;

Code:
Public j As Byte
Public RunWhen As Double
Public Const cRunIntervalSeconds = 10
Public Const cRunWhat = "HideFrames"
'
Sub StartTimer()
    RunWhen = Now + TimeSerial(0, 0, cRunIntervalSeconds)
    Application.OnTime RunWhen, cRunWhat, , True
End Sub
'
Sub HideFrames()
    j = j + 1
    If j > 5 Then
        Call StopTimer
        Exit Sub
    End If
    UserForm1.Controls("Frame" & j).Visible = False
    Call StartTimer
End Sub
'
Sub StopTimer()
    On Error Resume Next
    Application.OnTime RunWhen, cRunWhat, , False
End Sub

Run UserForm1 and hit CommandButton1 to see the effect.
 
Upvote 0
Re: Frame1.visiable = false

Thanks Haluk, code work all great, more over got the logic as well. thanks for the extended help.
 
Upvote 0

Forum statistics

Threads
1,214,653
Messages
6,120,748
Members
448,989
Latest member
mariah3

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