?
Solved

Producing a Stop watch.

Posted on 2003-03-27
3
Medium Priority
?
156 Views
Last Modified: 2010-05-01
I want to produce a stopwatch, (i.e. a timer) able to display minutes, seconds, miliseconds.  How will I get round doing this?

Thanks.
0
Comment
Question by:n-generation
[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
  • 2
3 Comments
 
LVL 28

Accepted Solution

by:
vinnyd79 earned 150 total points
ID: 8220446
0
 
LVL 28

Expert Comment

by:vinnyd79
ID: 8220496
actually doesn't look like that example handles milliseconds. You could try this link under downloads:

http://www.mvps.org/ccrp/

There is a hi-performance timer control.
0
 
LVL 1

Expert Comment

by:robertlees
ID: 8220630
Put the following declaration in a module:

Public Declare Function GetTickCount Lib "kernel32" () As Long

On your form, place a timer control (Timer1) with an interval of 1 (ie, 1 millisecond), and a label (Label1).

Private Sub Timer1_Timer()
    Static lngStart As Long
    Dim ms As Long
    Dim h As Long
    Dim m As Long
    Dim s As Long
   
    If lngStart = 0 Then
        lngStart = GetTickCount()  'first time
    End If
   
    'milliseconds since start
    ms = GetTickCount() - lngStart
   
    'break milliseconds into parts
    s = Int(ms / 1000)
    ms = ms - (s * 1000)
   
    m = Int(s / 60)
    s = s - (m * 60)
   
    h = Int(m / 60)
    m = m - (h * 60)
   
    'show current elapsed time
    Label1.Caption = Format(h) & ":" & Format(m, "00") & ":" & Format(s, "00") & "." & Format(ms, "000")
End Sub
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
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…
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

765 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