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

timers and loops - using varibles with them 1

Status
Not open for further replies.

maffoo

Programmer
Nov 11, 2000
5
0
0
GB
could someone advise me on the following please..

Please not, I don't use any text boxes or buttons in my applications,as they are automated...


I would like to do the following...


timedelay = 400000
delaysub
'program continues - basically allowing me to use lots of time delays, but being able to specify the last number each time I call the timedelay sub, to save on code and time.

Public sub delaysub
for i = 1 to timedelay
next i
End sub


or another option would be to use a timer control, but I am only a beginner, so I am still trying to learn.
Thanks Matt
 
The only problem with using the for next loops as a time delay is that all computers do not calculate at the same speed, so it is not accurate. I would suggest using either a timer (you can set the interval and the enabled property at run time) or use the sleep api.

Dim x As Long
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)


And call it like this
x = 1000
Call Sleep(x) ' to sleep for 1 second...





David Paulson


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top