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

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
Application.Wait (Now + TimeValue("0:00:20"))
 
Upvote 0
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.
 
Upvote 0
(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?
 
Upvote 0
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..
 
Upvote 0

Forum statistics

Threads
1,214,829
Messages
6,121,826
Members
449,051
Latest member
excelquestion515

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