Timer
Solved
le meruvien
Posted messages
1414
Status
Member
-
le meruvien Posted messages 1414 Status Member -
le meruvien Posted messages 1414 Status Member -
Hello,
I would like to create a simple form with a "minute" and "second" field that starts at zero as soon as the form is opened (and a reset button).
Thank you
Configuration: Windows / Chrome 79.0.3945.117
I would like to create a simple form with a "minute" and "second" field that starts at zero as soon as the form is opened (and a reset button).
Thank you
Configuration: Windows / Chrome 79.0.3945.117
5 answers
-
yg_be Posted messages 23437 Registration date Status Contributor Last intervention Ambassadeur 1 588
Hello,
this can be done by using the TimerInterval property of the form and the Timer event of the form.Private Sub Form_Load() Me.TimerInterval = 1000 'triggers every second End Sub Private Sub Form_Timer() 'modifies the timer display End Sub
-
-
yg_be Posted messages 23437 Registration date Status Contributor Last intervention Ambassadeur 1 588
Here is an example of code to include in the form code, with a button called zero and a label called timer.Option Compare Database Option Explicit Dim start As Date Private Sub Form_Load() start = Now() display_timer Me.TimerInterval = 1000 End Sub Private Sub form_timer() display_timer End Sub Private Sub zero_Click() start = Now() display_timer End Sub Private Sub display_timer() Dim duration As Date, minutes As Long, seconds As Integer duration = Now() - start minutes = Int(duration * 24 * 60) seconds = (duration * 24 * 60 - minutes) * 60 Me.timer.Caption = CStr(minutes) + "min " + CStr(seconds) + "sec" End Sub
-
well, it's not working!!
I've attached my file, you can take a look.
https://www.cjoint.com/c/JAmoybwaIOd
thank you -