Search Tools Links Login

Pause


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

About this post

Posted: 2002-06-01
By: ArchiveBot
Viewed: 86 times

Categories

Visual Basic 6

Attachments

No attachments for this post


Loading Comments ...

Comments

No comments have been added for this post.

You must be logged in to make a comment.