Hi,
I would like to create a countdown timer for a practice exam database that I am creating. The practice exam lasts up to 4.5 hours. I found this code from YouTube and it was created by someone as a 10 second timer. He created a command button called "btn_Timer." When you click the button, 10 seconds is displayed in the textbox, "txt.Time." This code works perfectly if I only want the timer to display in seconds. However, how can I use this code to create a timer that formats the time as HH:mm:ss (i.e., in hours, minutes, and seconds)? The code is below. Thanks!
Option Compare Database
Dim m_intTimer As Integer
Private Sub btnTimer_Click()
Me.TimerInterval = 1000
m_intTimer = 10 ' 10 seconds
Me.txtTime.SetFocus
Me.txtTime.Text = m_intTimer
Me.btnTimer.SetFocus
End Sub
Private Sub Form_Timer()
m_intTimer = m_intTimer - 1 ' count down
Me.txtTime.Value = m_intTimer 'show the time in a textbox
If m_intTimer = 0 Then
' do your event.
TimerInterval = 0 'Stop the timer
MsgBox "Time is up"
End If
End Sub
I would like to create a countdown timer for a practice exam database that I am creating. The practice exam lasts up to 4.5 hours. I found this code from YouTube and it was created by someone as a 10 second timer. He created a command button called "btn_Timer." When you click the button, 10 seconds is displayed in the textbox, "txt.Time." This code works perfectly if I only want the timer to display in seconds. However, how can I use this code to create a timer that formats the time as HH:mm:ss (i.e., in hours, minutes, and seconds)? The code is below. Thanks!
Option Compare Database
Dim m_intTimer As Integer
Private Sub btnTimer_Click()
Me.TimerInterval = 1000
m_intTimer = 10 ' 10 seconds
Me.txtTime.SetFocus
Me.txtTime.Text = m_intTimer
Me.btnTimer.SetFocus
End Sub
Private Sub Form_Timer()
m_intTimer = m_intTimer - 1 ' count down
Me.txtTime.Value = m_intTimer 'show the time in a textbox
If m_intTimer = 0 Then
' do your event.
TimerInterval = 0 'Stop the timer
MsgBox "Time is up"
End If
End Sub