Insert Timer Control and set its interval as 100.
Dim h, m, s, ms, abc As Integer
Private Sub btnStart_Stop_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStart_Stop.Click
If btnStart_Stop.Text = "START" Then
Timer1.Start()
btnStart_Stop.Text = "STOP"
btnReset.Enabled = False
Else
Timer1.Stop()
btnStart_Stop.Text = "START"
btnReset.Enabled = True
End If
End Sub
Private Sub btnReset_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnReset.Click
Label1.Text = "00:00:00:00"
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
abc = abc + 1
ms = abc
Label1.Text = h.ToString("D2") & ":" & m.ToString("D2") & ":" & s.ToString("D2") & ":" & ms.ToString("D2")
If abc = 10 Then
Label1.Text = h.ToString("D2") & ":" & m.ToString("D2") & ":" & s.ToString("D2") & ":" & ms.ToString("D2")
s = s + 1
abc = 0
End If
If s = 60 Then
m = m + 1
s = 0
End If
If m = 60 Then
h = h + 1
m = 0
End If
Label1.Text = h.ToString("D2") & ":" & m.ToString("D2") & ":" & s.ToString("D2") & ":" & ms.ToString("D2")
End Sub
No comments:
Post a Comment