Pause
![Visual Basic 6, or VB Classic Visual Basic 6, or VB Classic](https://www.fortypoundhead.com//assets/img/icons/v7/vb6.png)
Tired of having to pause in increments of 1 second? This coding will pauses based on MILLIseconds using the GetTickCount function.
Original Author: Shawn Neckelmann
Inputs
The number of seconds to pause for. You can put this value down to as little as a millisecond.
Assumptions
Use the CDbl type converter to avoid getting an Invalid Parameter Type error.
Ex:
dim lngPause as Long
lngPause = 2
Call Pause(CDbl(lngPause))
Returns
0
Side Effects
0
API Declarations
Declare Function GetTickCount Lib "kernel32" Alias "GetTickCount" () As Long 'this is for 32-bit versions of VB
'Declare Function GetTickCount& Lib "user" () 'this one is for 16-bit versions
Code
Sub Pause (ByVal hInterval As Double)
Dim hCurrent As Long
hInterval = hInterval * 1000
hCurrent = GetTickCount()
Do While GetTickCount() - hCurrent < hInterval
DoEvents
Loop
End Sub
Loading Comments ...
Comments
No comments have been added for this post.
You must be logged in to make a comment.