CPause (Class for pausing)
This is a class that you can use to make your app pause for a few hours/minutes/seconds or milliseconds. This will work even if midnight occurrs while pausing! (Thus, this is midnight-compliant, just like my CStopwatch class I submitted earlier.)
AI
AI Summary: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.
Source Code
'*************************************
'This goes into a class module
'Important: NAME THE MODULE "CPause"
'*************************************
Const iSecsInDay As Long = 86400
Enum iConstants
iSeconds = 0
iMinutes = 1
iHours = 2
iMilliSec = 3
End Enum
Public Function pPause(ByVal Number As Single, _
Optional ByVal Unit As iConstants)
Dim iStopTime, fakeTimer, sAfterMidnight, sBeforeMidnight
If Unit = iSeconds Then
Number = Number
ElseIf Unit = iMinutes Then
Number = Number * 60
ElseIf Unit = iHours Then
Number = Number * 3600
ElseIf Unit = iMilliSec Then
Number = Number / 1000
End If
fakeTimer = Timer
iStopTime = fakeTimer + Number
If iStopTime > iSecsInDay Then
sAfterMidnight = iStopTime - iSecsInDay
sBeforeMidnight = Number - sAfterMidnight
fakeTimer = Timer
While Timer < fakeTimer + sBeforeMidnight And Timer <> 0
DoEvents
Wend
fakeTimer = Timer
While Timer < fakeTimer + sAfterMidnight
DoEvents
Wend
Else 'if pausing won't continue through midnight
While Timer < iStopTime
DoEvents
Wend
End If
End Function
'************************************
'Put the following in the Declaration
'section of a form
'************************************
Dim mytimer as CPause
'***************************************************
'Put the following into any Sub (eg. Command1_Click)
'***************************************************
Set mytimer = New CPause
'to pause for 10 seconds, use the following call
i = mytimer.pPause(10, iSeconds)
'**************************************************
'End of Code
'I welcome any comments bug reports or enhancements that can be made!
'<c03jabot@prg.wcape.school.za>
Upload
Upload
Original Comments (3)
Recovered from Wayback Machine