Frame1.visible = false

vmjan02

Well-known Member
Joined
Aug 15, 2012
Messages
531
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.
 

Haluk

Rules Violation
Joined
Oct 26, 2002
Messages
1,075
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.
 

vmjan02

Well-known Member
Joined
Aug 15, 2012
Messages
531
Re: Frame1.visiable = false

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

Forum statistics

Threads
1,085,719
Messages
5,385,434
Members
401,951
Latest member
cryptolock

Some videos you may like

This Week's Hot Topics

Top