Millisecond capable timer in VBA

When debugging code in VBA, it can sometimes be useful to measure how long a particular action takes to complete. In-built functions such as Timer can return you a time as accurate as 1/64th of a second, but what if you need to compare times with a greater degree of accuracy?

The code you see below solves this problem by calling on an API function named ‘QueryPerformanceCounter’, which is capable of measuring times to a thousandth of a second. The code has been modified from the original snippet, which can be found here:
http://www.vbforums.com/showthread.php?545100-Time-Between-Events&p=3367886#post3367886

In order for the code to work, all you need to do is paste it into a normal code module.

Enjoy!

—–

 

About Roger Smith

Roger joined the team in 2010, and works full time at Gravity as an intern. His main role is to keep the accounts organised and up-to-date, but he also has a heavy hand in assisting other staff members in times of heavy workload. He keeps our company communicating through regular updates of our blog, Facebook page, and Twitter account. When he's not doing either the accounts or the social media, Roger is also responsible for drafting some of our technical documentation.

, , , , , ,

No comments yet.

Leave a Reply