469,297 Members | 2,141 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,297 developers. It's quick & easy.

Timing a proecess in Access2000

Is there as simple way to time a process (down to the ms) while
running Access2000 VBA code? I want to test the time taken to run
various functions.
Nov 12 '05 #1
4 2294
Save the time at the start and end of the function then output end - start
time.

"Lauren Quantrell" <la*************@hotmail.com> wrote in message
news:47**************************@posting.google.c om...
Is there as simple way to time a process (down to the ms) while
running Access2000 VBA code? I want to test the time taken to run
various functions.

Nov 12 '05 #2
la*************@hotmail.com (Lauren Quantrell) wrote in message news:<47**************************@posting.google. com>...
Is there as simple way to time a process (down to the ms) while
running Access2000 VBA code? I want to test the time taken to run
various functions.


use GetTickCount... from www.mvps.org/vbnet

'''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''
' Copyright 1996-2003 VBnet, Randy Birch, All Rights Reserved.
' Some pages may also contain other copyrights by the author.
'''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''
' Distribution: You can freely use this code in your own
' applications, but you may not reproduce
' or publish this code on any web site,
' online service, or distribute as source
' on any media without express permission.
'''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''
Private Declare Function GetTickCount Lib "kernel32" () As Long
Private tstart As Single

Private Enum ElapsedTimeType
ttMilliseconds = 1
ttSeconds = 2
ttMinutes = 3
End Enum
Private Function GetElapsedTime(dwTimeType As ElapsedTimeType) As Single

Dim divisor As Long

Select Case dwTimeType
Case ttMilliseconds: divisor = 1
Case ttSeconds: divisor = 1000
Case ttMinutes: divisor = 60000
End Select

GetElapsedTime = (GetTickCount() - tstart) / divisor

End Function
Private Sub Form_Load()

'Assign the current tick count
'as the tick start point. Failure
'to do this will return the number
'of ticks since Windows was last
'rebooted. (Note: elapsed time is
'stored as a DWORD value in Windows.
'Therefore, the time will wrap around
'to zero if the system is run continuously
'for 49.7 days. If a higher resolution
'timer is required, use a multimedia
'or high-resolution timer.
tstart = GetTickCount()

End Sub
Nov 12 '05 #3
On 3 Nov 2003 11:30:47 -0800, pi********@hotmail.com (Pieter Linden)
wrote:

Using GetTickCount, you could write your own class. I called mine
clsStopwatch, and it has methods like Start, Stop, and Peek.

Also please note that "down to the ms" may be somewhat difficult.
Simple timers like GetTickCount don't necessarily have that
resolution. If your function is fast, you may want to run it a
thousand or a million times, rather than once.

-Tom.

la*************@hotmail.com (Lauren Quantrell) wrote in message news:<47**************************@posting.google. com>...
Is there as simple way to time a process (down to the ms) while
running Access2000 VBA code? I want to test the time taken to run
various functions.


use GetTickCount... from www.mvps.org/vbnet

<clip>

Nov 12 '05 #4

"Lauren Quantrell" <la*************@hotmail.com> wrote in message
news:47**************************@posting.google.c om...
Is there as simple way to time a process (down to the ms) while
running Access2000 VBA code? I want to test the time taken to run
various functions.


dblTStart = Timer()
....Do something
dblTStop = Timer()
Debug.Print Int((dblTStop - dblTStart) * 1000) & " ms"

Erik Rudbeck
Nov 12 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Mike Metzger | last post: by
7 posts views Thread by jamie | last post: by
3 posts views Thread by gregory_may | last post: by
2 posts views Thread by Steven D'Aprano | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by harlem98 | last post: by
1 post views Thread by Geralt96 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.