VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Perfect Pause

by rbennett (3 Submissions)
Category: Miscellaneous
Compatability: Visual Basic 3.0
Difficulty: Unknown Difficulty
Date Added: Wed 3rd February 2021
Rating: (6 Votes)

Pauses an operation while allowing other operations to run. This pause is date and time based. The sleep function freezes your computer. The timer function and timer controls stop at midnight because they return to a 0 value. The perfect pause continues where these stop. It's highly configurable.

Inputs
'Seconds are inputed as seconds ( 1 = 1sec). A boolean is inputed for a quick 'exit, and an integer of 0 or 1 are inputted to determine the type of return.
Assumes
'it is assumed the user knows a small bit about programming and function calls 'within modules. It is assumed the users computer is keeping good time
Code Returns
'Returns a boolean

Rate Perfect Pause

'=========================
'Paste in a BAS module
'=========================
Option Explicit
Public exitPause As Boolean
Public Function timedPause(secs As Long)
 Dim secStart As Variant
 Dim secNow As Variant
 Dim secDiff As Variant
 Dim Temp%
 
 exitPause = False 'this is our early way out out of the pause
 
 secStart = Format(Now(), "mm/dd/yyyy hh:nn:ss AM/PM") 'get the starting seconds
 
 Do While secDiff < secs
 If exitPause = True Then Exit Do
 secNow = Format(Now(), "mm/dd/yyyy hh:nn:ss AM/PM") 'this is the current time and date at any itteration of the loop
 secDiff = DateDiff("s", secStart, secNow) 'this compares the start time with the current time
 Temp% = DoEvents
 Loop 
End Function
'=============================
'Paste in a form with 1 command button
'=============================
Option Explicit
Private Sub Command1_Click()
 
 timedPause 25
 
 MsgBox "Time is up buddy!"
End Sub

Download this snippet    Add to My Saved Code

Perfect Pause Comments

No comments have been posted about Perfect Pause. Why not be the first to post a comment about Perfect Pause.

Post your comment

Subject:
Message:
0/1000 characters