STOPWATCH

Posted on at


 

 

 

Public Class frmcountdown

 

Private Sub btnreset_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnreset.Click
lblhours.Text = "00"
lblmin.Text = "00"
lblsec.Text = "00"
Timer1.Enabled = False
End Sub

Private Sub btnstart_pause_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnstart_pause.Click
If btnstart_pause.Text = "START" Then
Timer1.Enabled = True
btnok.Enabled = False
btnstart_pause.Text = "PAUSE"
ElseIf btnstart_pause.Text = "PAUSE" Then
Timer1.Enabled = False
btnreset.Enabled = True
btnok.Enabled = True
btnstart_pause.Text = "START"
End If
End Sub

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Timer1.Interval = 1000
If lblhours.Text = "" Then
lblhours.Text = "0"
End If
If lblmin.Text = "" Then
lblmin.Text = "0"
End If
If lblsec.Text = "" Then
lblsec.Text = "0"
End If
If lblhours.Text = "00" Then
lblhours.Text = "0"
End If
If lblmin.Text = "00" Then
lblmin.Text = "0"
End If
If lblsec.Text = "00" Then
lblsec.Text = "0"
End If
If lblsec.Text > "0" Then
lblsec.Text = lblsec.Text - 1
End If
If lblmin.Text > "0" Then
If lblsec.Text = "0" Then
lblmin.Text = lblmin.Text - 1
lblsec.Text = "59"
End If
End If
If lblhours.Text > "0" Then
If lblmin.Text = "0" Then
If lblsec.Text = "0" Then
lblhours.Text = lblhours.Text - 1
lblmin.Text = "59"
lblsec.Text = "59"
End If
End If
End If

If lblsec.Text = "0" Then
If lblmin.Text = "0" Then
If lblhours.Text = "0" Then
Timer1.Enabled = False
MsgBox("Time is up")
btnstart_pause.Text = "Start"
btnreset.Enabled = False
End If
End If
End If
End Sub

Private Sub btnok_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnok.Click
If txtsec.Text = "00" Then
If txtmin.Text = "00" Then
If txthours.Text = "00" Then
btnstart_pause.Enabled = False
MsgBox("Please enter a value heigher then 0")
End If
End If
End If
If txtsec.Text = "0" Then
If txtmin.Text = "0" Then
If txthours.Text = "0" Then
btnstart_pause.Enabled = False
MsgBox("Please enter a value heigher then 0")

End If
End If
End If
If txtsec.Text = "" Then
txtmin.Text = ""
txthours.Text = ""
btnstart_pause.Enabled = False
MsgBox("Please enter a value")

End If
btnok.Enabled = True
lblhours.Text = txthours.Text
lblmin.Text = txtmin.Text
lblsec.Text = txtsec.Text
If lblhours.Text > "0" Then
btnstart_pause.Enabled = True
End If
If lblmin.Text > "0" Then
btnstart_pause.Enabled = True
End If
If lblsec.Text > "0" Then
btnstart_pause.Enabled = True
End If

End Sub



About the author

alyka

Happy Person

Subscribe 0
160