?
Solved

VB4:Timer as precise stop-watch

Posted on 1997-08-03
1
Medium Priority
?
407 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 150 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 does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
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…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

719 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