VBA Code:
Option Explicit
Dim CmdStop As Boolean
Dim Paused As Boolean
Dim Start
Dim TimerValue As Date
Dim pausedTime As Date
Sub btnStart_Click()
CmdStop = False
Paused = False
Start = Now() ' Set start time.
btnPause.Enabled = True
btnStop.Enabled = True
btnReset.Enabled = False
Do While CmdStop = False
If Not Paused Then
TimerValue = Now() - Start - pausedTime
Else
pausedTime = Now() - TimerValue - Start
End If
TimerReadOut.Caption = Format(TimerValue, "h:mm:ss")
DoEvents ' Yield to other processes.
Loop
End Sub
Sub btnPause_Click()
If btnPause.Caption = "Pause" Then
Paused = True
btnPause.Caption = "Continue"
Else
Paused = False
btnPause.Caption = "Pause"
End If
End Sub
Sub BtnReset_Click()
TimerReadOut.Caption = "0:00:00"
btnStop.Enabled = False
End Sub
Sub BtnStop_Click()
btnPause.Enabled = False
btnReset.Enabled = True
btnStop.Enabled = False
CmdStop = True
End Sub
Can someone PLEASE PLEASE assist, keeps on saying that I have not declared a variable on all macros? The buttons are not working and I have assigned the macros to them.
I attached my workbook as well to show my buttons.
What am I missing?