View Single Post
  #8 (permalink)  
Old 06-04-2008, 03:41 AM
obliviongoty obliviongoty is offline
Newbie
 
Join Date: Jun 2008
Posts: 1
Rep Power: 0
obliviongoty is on a distinguished road
Default Re: Tutorial - A Simple Stropwatch!

I made some improvements to the code and renamed the objects, all credit to travy92 though. Now there is one button for start and stop and a minutes label too, the seconds reset to 0.00 when a minute ticks over. The reset button will also not be a problem if it is used while the counter is still going.

To make this work you will need to rename the objects to the appropriate names used in this code and add a Label called lblTimeMins

Code:
Private Sub cmdExit_Click()
    End
End Sub



Private Sub cmdReset_Click()
    If tmrStopWatch.Enabled = True Then
        tmrStopWatch.Enabled = False
        lblTimeMS.Caption = "0.00"
        lblTimeMins.Caption = "0"
    Else
        lblTimeMS.Caption = "0.00"
        lblTimeMins.Caption = "0"
    End If
End Sub



Private Sub cmdStopStart_Click()
    If tmrStopWatch.Enabled = False Then
        tmrStopWatch.Enabled = True
    Else
        tmrStopWatch.Enabled = False
    End If
End Sub



Private Sub Form_Load()
    tmrStopWatch.Enabled = False
End Sub



Private Sub tmrStopWatch_Timer()
    lblTimeMS.Caption = Format(Val(lblTimeMS.Caption) + 0.01, "fixed")
    If lblTimeMS.Caption = "60.00" Then
        lblTimeMins.Caption = lblTimeMins + 1
        lblTimeMS.Caption = "0.00"
    End If
End Sub

Last edited by TcM; 06-04-2008 at 08:47 AM.
Reply With Quote