VBcoders Browse New Submit Contact Sign In

No account? Register free

Forgot password?

Timer Class Module

James Arnold  (1 Submission)   VB function enhancement   VB Script   Beginner   Wed 3rd February 2021

This class module contains everything needed for creating a timer. It is very simple (18 lines), but provides millisecond accuracy using the GetTickCount API.

Assumes
To start the timer: MyTimer.StartTimer To stop the timer: MyTimer.StopTimer To read duration: MyTimer.ElapsedTime

Returns
Duration the timer has been running in milliseconds (divide by 1000 for seconds).

Side Effects
Due to the fact this is a class module the timer will continue to run even if a message box is displayed - the normal VB timer will pause when a messagebox is displayed. This can be an advantage or disadvantage, so take note.

API Declarations
Dim myTimer as timTimer
Set myTimer = New timTimer

Rate Timer Class Module (2(2 Vote))

Download Timer Class Module

Timer Class Module Comments

No comments yet — be the first to post one!

Post a Comment

0/1000 characters