by Stanley Campbell (1 Submission)
Category: Miscellaneous
Compatability: Visual Basic 4.0 (32-bit)
Difficulty: Unknown Difficulty
Originally Published: Thu 18th February 1999
Date Added: Mon 8th February 2021
Rating: (1 Votes)
Delay execution of code for a Number of seconds.
Private Sub Timer2_Timer()
Dim DelayTime As Long
Dim EndTime As Long
DelayTime = 22 'Set Delay in Seconds.
EndTime = Format(Time, "s") + DelayTime
If EndTime > 59 Then
'Make sure Seconds is Not Greater than 59.
EndTime = EndTime - 59
End If
Do Until Format(Time, "s") = EndTime
'Yields execution so that the operating system can process other events.
DoEvents
Loop
'Turn Timer Off.
Timer2.Enabled = False
End Sub