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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to Delay for 5 seconds? 3

Status
Not open for further replies.

Blitz

Technical User
Jul 7, 2000
171
US
I have a program that sends keystrokes to another program but the program runs too fast. I need to put a 5 second delay after each sendkeys to give the other program time to process it. is there any easy way to do this?
 
What you want to do is add a Timer control to your form. Write a Sub like this:<br><br><br>&nbsp;Sub Wait(second as single)<br><br>&nbsp;&nbsp;Dim Starttime as Single<br><br>&nbsp;&nbsp;Starttime = Timer<br>&nbsp;&nbsp;<br>&nbsp;&nbsp;Do While Timer &lt; Starttime + Second<br>&nbsp;&nbsp;DoEvents (optional)<br><br>&nbsp;&nbsp;Loop<br><br>&nbsp;&nbsp;End Sub<br><br>&nbsp;&nbsp;Now do a Call Wait (seconds)&nbsp;&nbsp;i.e. Call Wait (4) - Wait four seconds. Whatever you assign the seconds variable is how many seconds the program will wait before it continues to execute.<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Hope this helps<br>&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;John Stephens<br><br>&nbsp;&nbsp;
 
Thanks it worked perfectly
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top