?
Solved

Time performance in VBA

Posted on 2005-04-26
5
Medium Priority
?
387 Views
Last Modified: 2012-08-14
Ola,

How do I count the ammount of cycles / miliseconds / ticks or what ever of smallest unit of time there is to excecute a statement.

Something like this:

Start = SomethingToMeasureTime
' do some statment(s)
End = SomethingToMeasureTime

Msgbox End - Start
0
Comment
Question by:DaFou
  • 3
5 Comments
 
LVL 11

Expert Comment

by:Jokra_the_Barbarian
ID: 13870135
This should give you some ideas on what you need to do:  http://support.microsoft.com/?kbid=233275
0
 
LVL 39

Expert Comment

by:thenelson
ID: 13870260
Dim StartTime As Double

StartTime = CDbl(Now)
' do some statment(s)
Debug.Print (CDbl(Now) - StartTime)

this will give you the number of seconds with 15 significant digits.
0
 
LVL 2

Author Comment

by:DaFou
ID: 13870352
thenelson,

Dim StartTime As Double
    StartTime = CDbl(Now)

    Dim lDblYield As Double
   
    Dim obj As Object
    Set obj = CreateObject("Excel.Application")
    MsgBox (CDbl(Now) - StartTime)

displays 0.

ANd i cant beleive it takes 0.0000000 time to instantiate an excell application
0
 
LVL 39

Expert Comment

by:thenelson
ID: 13870580
Oops!  I just read that Now returns to time to the nearest second so change "Now" to "Timer":

Dim StartTime As Double
    StartTime = CDbl(Timer)

    Dim lDblYield As Double
   
    Dim obj As Object
    Set obj = CreateObject("Excel.Application")
    MsgBox (CDbl(Timer) - StartTime)
0
 
LVL 39

Accepted Solution

by:
thenelson earned 2000 total points
ID: 13870610
And actually Timer returns a single so:

Dim StartTime As Single
    StartTime = Timer

    Dim lDblYield As Double
   
    Dim obj As Object
    Set obj = CreateObject("Excel.Application")
    MsgBox Timer - StartTime
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question