04-05-2003, 06:57 AM
I was just wondering if it's possible to set a timer on a userform?
I want the userform to appear but disappear in say five seconds.
Can i use the following code in a certain way ?
Application.OnTime Now + TimeValue("00:00:05"), "test"
04-05-2003, 08:48 AM
With a little modification you could use something like this :
Private Sub CommandButton1_Click()
Dim Count As Integer
For Count = 30 To 1 Step -1
Range("A1").Value = Count & " Seconds..."
Application.Wait Now + TimeSerial(0, 0, 1)
04-07-2003, 05:55 AM
Thanks for the help Italkid but my question was:
How can i make a userform disapear using a timer ?
I tried your code and it doesn't work i put it in the userform ( Activate ) or ( Initialize ) and no result. I'm sure there's a way but how ???
Here's one way, but it seems somewhat eratic.
Debug.Print "UnloadForm was called"
Private Sub UserForm_Activate()
Application.OnTime Now + TimeValue("00:00:05"), "UnloadForm"
If you run the macro called Test, the form will be loaded and then unloaded 5 seconds later.
04-07-2003, 07:20 AM
Like this ?
Private Sub Workbook_Open()
Application.OnTime Now + TimeValue("00:00:05"), "HideForm"
And in a Module
Like this ?
Yes, that should work, I think.
04-07-2003, 07:48 AM
but now i have another problem...the userform goes away but also it stop from executing the rest of the code..
just to put you guys in the context.
It's a game. userform shows
the player bets on a horse but here's the problem: I want to give him only about 20 seconds to choose but after that the code has to continue. validate the results, calculate stats, etc.
so unload userform doesn't work out for this situation.
I simply want to do a hide like if i press on a command button.
Is there a way ?
Where is the code that is being stopped?
You could just do Userform1.Hide instead of unloading it.
04-07-2003, 08:23 AM
Thanks a lot Mill I think it works :) :D :)