Public Class match_timer '--[MATCH SETTINGS]--------------- Private _set_minutes As Integer Private _set_seconds As Integer '--[MATCH SETTINGS]--------------- Private _run_minutes As Integer Private _run_seconds As Integer '--[MATCH SETTINGS]--------------- Private _timeUp As Boolean Private _last10Sec As Boolean '--[MATCH SETTINGS]--------------- Private _stop As Boolean Private _start As Boolean Private _pause As Boolean Private _continue As Boolean Public Sub New(minutes As Integer, seconds As Integer) ' In Case Negative Numbers Where Set If minutes < 0 Then MsgBox("Sorry You Cant Set Negative Numbers", vbOKOnly + vbCritical, "Wrong Setting") Exit Sub End If ' Timing Setup _set_minutes = minutes _set_seconds = seconds ' Copy To Running Timer _run_minutes = _set_minutes _run_seconds = _set_seconds ' Control Bits _stop = False _start = False _pause = True _continue = False ' Timer Flags _timeUp = False _last10Sec = False End Sub ReadOnly Property ReadMinutes As Integer Get Return _run_minutes End Get End Property ReadOnly Property ReadSeconds As Integer Get Return _run_seconds End Get End Property ReadOnly Property ReadTime() As String Get Return Zero(_run_minutes) + ":" + Zero(_run_seconds) End Get End Property ReadOnly Property TimeUp() As Boolean Get Return _timeUp End Get End Property ReadOnly Property Last10Sec() As Boolean Get Return _last10Sec End Get End Property Public Sub Run() If _pause = False And _start = True Or _stop = False Then If _run_minutes > 0 And _run_seconds = 0 Then _run_minutes -= 1 _run_seconds = 59 ElseIf _run_minutes >= 0 And (_run_seconds > 0 And _run_seconds <= 59) Then _run_seconds -= 1 DetectLast10Sec(_run_seconds) ElseIf _run_minutes = 0 And _run_seconds = 0 Then _timeUp = True End If End If End Sub Private Sub DetectLast10Sec(seconds As Integer) If seconds >= 0 And seconds < 10 Then _last10Sec = True Else _last10Sec = False End If End Sub Public Sub StartTime() If _stop = False Then _start = True _pause = False Else MsgBox("Cant Start Timer When Its Already Finished Count Down", vbOKOnly + vbInformation, "Timer Message") End If End Sub Public Sub StopTime() If _start = True Then _pause = True _stop = True Else MsgBox("Cant Stop Timer When Its Not Even Started", vbOKOnly + vbInformation, "Timer Message") End If End Sub Public Sub PauseTime() If _start = True And _stop = False Then _pause = True Else MsgBox("Cant Pause Timer When (Not Started) Or Ended", vbOKOnly + vbInformation, "Timer Message") End If End Sub Public Sub ResumeTime() If _start = True And _stop = False Then _pause = False Else MsgBox("Cant Resume Timer When (Not Started) Or Ended", vbOKOnly + vbInformation, "Timer Message") End If End Sub Public Sub ResetTime() If _start = True And _stop = False Then ' Display A Message For The User To Choose Dim iAsk As DialogResult = MessageBox.Show("Would You Like To Stop And Reset The Timer ?", "Timer Message", MessageBoxButtons.YesNo, MessageBoxIcon.Question) ' Checking The Dialog Result If iAsk = DialogResult.Yes Then ' Its Safe To Do A Reset Reset_Time() End If ElseIf _start = True And _stop = True Then ' Its Safe To Do A Reset Reset_Time() End If End Sub Private Sub Reset_Time() _start = False _pause = True _stop = False _run_minutes = _set_minutes _run_seconds = _set_seconds End Sub Private Function Zero(Number As Integer) As String If Number >= 0 And Number < 10 Then Return "0" + Number.ToString Else Return Number.ToString End If End Function End Class