Time Function

Digitborn.com

Active Member
Joined
Apr 3, 2007
Messages
353
Hello,

I'd like when 20 seconds past from Frame1.Visible = True, to become Frame1.Visible = False. Is it possible? How can I do it?

Is it an Event thing or a function with Now()!? Thanks in advance

p.s. the Frame1 control is on a UserForm
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)

ADAMC

Well-known Member
Joined
Mar 20, 2007
Messages
1,169
Office Version
  1. 2013
Platform
  1. Windows
Application.Wait (Now + TimeValue("0:00:20"))
 

HalfAce

MrExcel MVP
Joined
Apr 6, 2003
Messages
9,456
Hello Digitborn,
Here's one example of that.
In a standard module, you can have something like this:
Code:
Sub DismissFrameVisability()
UserForm1.Frame1.Visible = False
End Sub
Then, (for this example it's using a CommandButton on the userform to make Frame1 visible),
you could use something like this:
Code:
Private Sub CommandButton1_Click()
Me.Frame1.Visible = True
Application.OnTime Now + TimeSerial(0, 0, 10), "DismissFrameVisability"
End Sub

Hope it helps.
 

Digitborn.com

Active Member
Joined
Apr 3, 2007
Messages
353

ADVERTISEMENT

(EDIT)

Question - why Application.Wait (Now + TimeValue("0:00:05")) is not working!? After 5 seconds it doesn't change the frame BackColor and Picture:
Code:
Private Sub CommandButton1_Click()
            Frame1.Visible = True
            Frame1.Caption = "testest"
            CommandButton1F1.ControlTipText = "Edit"
            CommandButton2F1.ControlTipText = "Delete"
            Label1F1.Caption = "Test " & .Cells(lRow, 10).Value & "!"
            Application.Wait (Now + TimeValue("0:00:05"))
            Frame1.BackColor = &HFF
            Frame1.Picture = LoadPicture("D:\a\My Pictures\new\exit-icon.jpg")
            Frame1.PictureAlignment = fmPictureAlignmentTopRight
            Application.Wait (Now + TimeValue("0:00:10"))
            Frame1.Visible = False
End Sub

If I do the following:

1st - Application.Wait (Now + TimeValue("0:00:02"))
2nd - Application.Wait (Now + TimeValue("0:00:04"))

it works

1st - Application.Wait (Now + TimeValue("0:00:04"))
2nd - Application.Wait (Now + TimeValue("0:00:06"))

it works too...the other digits don't work.

Also I have commandbuttons and a label within the Frame1 control. Why I can't click on the CommandButtons until Frame1 control is visible = true!?

I see that's because of Application.Wait. Is it possible to do this while you're still working something on the UserForm?
 

Digitborn.com

Active Member
Joined
Apr 3, 2007
Messages
353
HalfAce,

In a standard module, you can have something like this: Code:
Sub DismissFrameVisability()
UserForm1.Frame1.Visible = False
End Sub

Then, (for this example it's using a CommandButton on the userform to make Frame1 visible),
you could use something like this: Code:
Private Sub CommandButton1_Click()
Me.Frame1.Visible = True
Application.OnTime Now + TimeSerial(0, 0, 10), "DismissFrameVisability"
End Sub

It's not working at all. I don't know why! In VBA Help it's

Example
This example runs my_Procedure 15 seconds from now.

Application.OnTime Now + TimeValue("00:00:15"), "my_Procedure"

I've tried like this with the time format, but it's not working again.

I've tried to put the procedure:

In Userform, Declarations section:
Sub DismissFrameVisability()
UserForm1.Frame1.Visible = False
End Sub

Private Sub DismissFrameVisability()
UserForm1.Frame1.Visible = False
End Sub

Private Function DismissFrameVisability()
UserForm1.Frame1.Visible = False
End Sub

In a standart module:
Public Sub DismissFrameVisability()
UserForm1.Frame1.Visible = False
End Sub

Sub DismissFrameVisability()
UserForm1.Frame1.Visible = False
End Sub

Nothing happens...doesn't make visible = false at all..
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,152,160
Messages
5,768,537
Members
425,480
Latest member
br400821

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