Solved

VB4:Timer as precise stop-watch

Posted on 1997-08-03
1
401 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
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…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

739 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