John Colby
jcolby at colbyconsulting.com
Wed Jun 25 08:47:12 CDT 2003
Rocky, Here is the class I use for timing things such as the opening of forms and such, with a timer test function you can place in a module to play around with the class. Dead simple to use. The nice thing about using a class is that you can have as many instances as you need timing various stuff since the variable tracking elapsed time is private to the class instance. Option Compare Database Option Explicit Dim mclsTimer As clsTimer Function TestTimer() Set mclsTimer = New clsTimer MsgBox "Hit any key to continue", , "TIMER TEST 1" MsgBox mclsTimer.EndTimer & " ms elapsed time - Hit any key to continue", , "TIMER TEST 1" MsgBox mclsTimer.EndTimer & " ms total elapsed time - Hit any key to continue", , "TIMER TEST 2" mclsTimer.StartTimer MsgBox "Hit any key to continue", , "TIMER TEST 3" MsgBox mclsTimer.EndTimer() & " ms elapsed time", , "TIMER TEST3" Set mclsTimer = Nothing End Function Option Compare Database Option Explicit '.=============================================================== '.Copyright 2001 Colby Consulting. All rights reserved. '.E-mail : jcolby at colbyconsulting.com '.=============================================================== ' DO NOT DELETE THE COMMENTS ABOVE. All other comments in this module ' may be deleted from production code, but lines above must remain. '--------------------------------------------------------------------- '.Description : Implements the instantiated class for: clsTimer '. '.Written By : John W. Colby '.Date Created : 05/28/2001 ' Rev. History : ' ' Comments : '--------------------------------------------------------------------- '. ' ADDITIONAL NOTES: ' '--------------------------------------------------------------------- ' ' INSTRUCTIONS: '--------------------------------------------------------------------- '. 'THESE CONSTANTS AND VARIABLES ARE USED INTERNALLY TO THE CLASS '*+ Class constant declaration '*- Class constants declaration '*+ Class variables declarations '*- Class variables declarations 'THESE CONSTANTS AND VARIABLES ARE USED BY THE CLASS TO 'IMPLEMENT CLASS FUNCTIONALITY Private Declare Function apiGetTime Lib "winmm.dll" _ Alias "timeGetTime" () As Long '*+ custom constants declaration '*- Custom constants declaration '*+ custom variables declarations Dim lngStartTime As Long '*- custom variables declarations 'THESE FUNCTIONS / SUBS ARE USED INTERNALLY TO THE CLASS '*+ Private Init/Terminate Interface Private Sub Class_Initialize() StartTimer End Sub '*- Public Init/Terminate interface '*- Parent/Child links interface 'THESE FUNCTIONS / SUBS ARE USED TO IMPLEMENT CLASS FUNCTIONALITY '*+Class function / sub declaration Function EndTimer() As Long EndTimer = apiGetTime() - lngStartTime End Function Sub StartTimer() lngStartTime = apiGetTime() End Sub Function RawTime() As Long RawTime = apiGetTime() End Function '*-Class function / sub declaration John W. Colby www.colbyconsulting.com -----Original Message----- From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com]On Behalf Of Rocky Smolin - Beach Access Software Sent: Tuesday, June 24, 2003 12:08 AM To: AccessD at databaseadvisors.com Subject: [AccessD] Time in milliseconds Dear List: Is it possible to access/store/display the time in increments smaller than seconds. I need to time something in fractions of a second. MTIA Rocky -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://databaseadvisors.com/pipermail/accessd/attachments/20030625/60c28e7d/attachment-0001.html>