rbichon
asked on
Msgbox with timeout
I would like to create a message box that pops up, and if an answer is not selected (Yes, No Cancel) in a set number of seconds then the box will go away and default to Cancel.
One way I have seen to do this is with a vbscript object:
Set sh = CreateObject("WScript.Shel l")
TimeoutPopUp = sh.PopUp("Would you like to undo your changes?", 15, "Form Idle", 36)
The problem with this is that the timeout (15 sec in this case) seems to be sensitive to the timerinterval of the form. For some reason, if the timerinterval is set to 100, the popup box times out in about 15 seconds. If it is set to 1000, the popup box times out in less than a second. It also seems to be sensitive to the speed of the computer.
How can I get a msgbox to timeout at exactly 15 seconds?
One way I have seen to do this is with a vbscript object:
Set sh = CreateObject("WScript.Shel
TimeoutPopUp = sh.PopUp("Would you like to undo your changes?", 15, "Form Idle", 36)
The problem with this is that the timeout (15 sec in this case) seems to be sensitive to the timerinterval of the form. For some reason, if the timerinterval is set to 100, the popup box times out in about 15 seconds. If it is set to 1000, the popup box times out in less than a second. It also seems to be sensitive to the speed of the computer.
How can I get a msgbox to timeout at exactly 15 seconds?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Now you set the timer interval to 1000.
How this works is that myTime is set as 1 when teh form opens.
It increases every second
If it reaches 60000, it will fire the myExitMessage code IF statement.
Idea...?
How this works is that myTime is set as 1 when teh form opens.
It increases every second
If it reaches 60000, it will fire the myExitMessage code IF statement.
Idea...?
ASKER
Or I could set the interval to 60000 (60 seconds) and have it execute the code without the IF statement. Either way, that did the trick. Thanks.
Create a form with this code on the OnTimer event:
myTime = myTime + 1
myExitMessage
On the OnOpen event, have this:
myTime = 1
In teh declarations (after option explicit at the top of teh form module) have this:
Private myTime as Long
Then add this function
Function myExitMessage()
If myTime >= 60000 then '1 minute
'close form code
End if
End Function