This time delay code listing works great in our Wingding Match game in Excel. Therefore, we think you could use it in your projects too. The code is in Visual Basic for Applications (or VBA) format.
VBA code listing for time delay
Below is code to delay or pause a program for a certain amount of seconds.
Private Sub Time_Delay(secs As Single)
Dim startTime As Variant
startTime = Timer 'assign current time to a variable
Do While Timer < startTime + secs 'continue loop until appropriate seconds elapse
DoEvents 'allow other processes to run
Loop
End Sub
Keep in mind, this code was developed in 2008, and it still works. However, you may want to upgrade it; make it better. So, feel free to modify this code for your own purposes.
Questions and suggestions
If you have any questions, comments, or suggestions, then contact me at info@alexshaw3rd.com.
YouTube LinkedIn