Solved

VB4:Timer as precise stop-watch

Posted on 1997-08-03
1
391 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
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
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…

772 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now