Solved

VB4:Timer as precise stop-watch

Posted on 1997-08-03
1
399 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

820 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