Solved

VB4:Timer as precise stop-watch

Posted on 1997-08-03
1
398 Views
Last Modified: 2008-03-03
It's a big problem for me, I started a project with Visual Basic 4 and I cannot find a way to use the timer as a proper stop-watch.
I want to start the timer, to stop it when a user click on the mouse and get the time between, I need something very precise (millisecond).
It is possible with Visual Basic. I need an answer very quickly because if it's not, I will have to choose another programming interface.
Thanks a lot.
Stephanie
0
Comment
Question by:stephany080397
1 Comment
 

Accepted Solution

by:
Solo earned 50 total points
ID: 1429465
Use the GetTickCount API call, very accurate as it returns the number of milliseconds that have elapsed since Windows was started.
Store the initial result, and re-call the API every time u need to get an elapsed period, and just calculate the difference to get the elapsed time.
Define like this :
Public Declare Function GetTickCount Lib "kernel32" Alias "GetTickCount"() As Long

and use like this :
Dim T0 As Long   'Initial time
Dim T1 As Long   'Current time

...
T0 = GetTickCount   ' "Start" the timer, i.e.begin to count time
....
Private cmdStop_Click()
   T1 = GetTickCount - T0   ' Difference in milliseconds
...
End Sub

Well, hope it helps, bye


0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

Suggested Solutions

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

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