Option Explicit
Private m_StopTime As Date
Private Sub
cmdGo_Click()
Dim fields() As String
Dim hours As Long
Dim minutes As Long
Dim seconds As Long
fields = Split(txtDuration.Text, ":")
hours = fields(0)
minutes = fields(1)
seconds = fields(2)
m_StopTime = Now'''''
this uses the PC's RTC current time, how can this become the future Stop time.????
m_StopTime = DateAdd("h", hours, m_StopTime)
m_StopTime = DateAdd("n", minutes, m_StopTime)
m_StopTime = DateAdd("s", seconds, m_StopTime)
tmrWait.Enabled = True
End Sub
Private Sub
tmrWait_Timer()
Dim time_now As Date
Dim hours As Long
Dim minutes As Long
Dim seconds As Long
time_now = Now' this again uses the PC's RTC current time.
If time_now >= m_StopTime Then'
BUT the Stop time was in the past.!
so how will can you compare the Past Stop time with the current Now time which is increasing away from the Start time.
[this, THEN is always TRUE]
Me.WindowState = vbMaximized
tmrWait.Enabled = False
lblRemaining.Caption = "0:00:00"
Else
seconds = DateDiff("s", time_now, m_StopTime)
minutes = seconds \ 60
seconds = seconds - minutes * 60
hours = minutes \ 60
minutes = minutes - hours * 60
lblRemaining.Caption = _
Format$(hours) & ":" & _
Format$(minutes, "00") & ":" & _
Format$(seconds, "00")
End If
End Sub
what is red is the problem, that time = now and clicking on the button "go" again starts counting again