Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I create a timer??

Status
Not open for further replies.

Oxymoron

Technical User
Dec 17, 2000
168
0
0
GB
I would like to create a vb script that would ask a user to input a number of seconds (e.g. InputBox)
This number would then be the amount of time before an event or comand would be executed.
e.g.

dim number_seconds, Shell
number_seconds=InputBox("please enter the amount of seconds you would like the computer to delay shutting down")
***number inputted applied to timer function to produce delay***
then
Set Shell=WScript.CreateObject("WScript.Shell")
Shell.Run "Run Dll32.exe user.exe,ExitWindows"
I'm sorry if this isn't too clear, all I want is to know the code for a timer.If anyone can help I'd be really grateful.
Thanks y'all
JoE
 
You weren't clear about context. If you want a "delay" rather than a timer, and you're trying to pause a WSH VBScript, then you can use Sleep as in:
Code:
Const gstrTitle = "The pause that refreshes!"
Dim wshShell, intDelay

set wshShell = WScript.CreateObject("WScript.Shell")
intDelay = InputBox("Enter seconds to wait before " _
                  & "calculator pops up.", _
                    gstrTitle)
WScript.Sleep intDelay * 1000
WshShell.Run "calc"
The delay value is specified in milliseconds, thus the factor of 1000 used here.

See to find this and a whole lot of other scripting answers.
 
hey, it seems to me that you want to place a script to sleep, but rather then to specify a specific number of seconds in the script, you want the user be given this option. Assuming I am correct, try this code:

'******************************

Dim returntext
returntext = InputBox("Please enter the amount of seconds you want to wait:")

Wscript.Sleep returntext * 1000

Wscript.Echo "Finished waiting."

'*************************************

Cool?
Mark my thread if it's helpful, thanx

Aladdin420
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top