Kellaroo
03-06-2022, 10:00 PM
I'm trying to find a way of pausing a timer that uses input from a textbox.
If there is a way of making a pause directly with VBA then that would solve my problem immediately, but I don't know how to do that (I need a 'pause' to work indefinitely, not specified for 10sec).
My way of doing this is to have the 'pause button' make visible another textbox that copies the value of the timer textbox. Then I can re-input that value to resume the countdown.
For example, if the timer states 00:01:30 at the time of pressing the pause button, then the copied timer will read 00:01:30.
Now I can take that value later and re-input it into the timer, effecting a pause/ resume.
My problem is that the timer won't take input in the form of hh:mm:ss, and if I remove the colons it won't translate well (i.e. 1:30 becomes 130, which is understood as 130 seconds instead of 90 seconds).
Hopefully that ^ can be understood. It's difficult to put words on the exact problem. Here is the code and the PPT where you can see the problem in action.
How can I make this code accept the hh:mm:ss format as input, instead of a seconds integer?
Sub countdown()
Dim time As Date
time = Now()
Dim count As Integer
count = ActivePresentation.Slides(1).Shapes("TimeLimit").TextFrame.TextRange
time = DateAdd("s", count, time)
Do Until time < Now()
DoEvents
ActivePresentation.Slides(1).Shapes("countdown").TextFrame.TextRange = Format((time - Now()), "hh:mm:ss")
Loop
End Sub
I see the solution being something like:
1. An entirely different way to pause a countdown with VBA
2. A way to make this countdown timer receive input in the format of hh:mm:ss
3. A way to convert the hh:mm:ss format back into seconds integer
Any of these things would effectively fix my problem.
Thank you for your consideration!
If there is a way of making a pause directly with VBA then that would solve my problem immediately, but I don't know how to do that (I need a 'pause' to work indefinitely, not specified for 10sec).
My way of doing this is to have the 'pause button' make visible another textbox that copies the value of the timer textbox. Then I can re-input that value to resume the countdown.
For example, if the timer states 00:01:30 at the time of pressing the pause button, then the copied timer will read 00:01:30.
Now I can take that value later and re-input it into the timer, effecting a pause/ resume.
My problem is that the timer won't take input in the form of hh:mm:ss, and if I remove the colons it won't translate well (i.e. 1:30 becomes 130, which is understood as 130 seconds instead of 90 seconds).
Hopefully that ^ can be understood. It's difficult to put words on the exact problem. Here is the code and the PPT where you can see the problem in action.
How can I make this code accept the hh:mm:ss format as input, instead of a seconds integer?
Sub countdown()
Dim time As Date
time = Now()
Dim count As Integer
count = ActivePresentation.Slides(1).Shapes("TimeLimit").TextFrame.TextRange
time = DateAdd("s", count, time)
Do Until time < Now()
DoEvents
ActivePresentation.Slides(1).Shapes("countdown").TextFrame.TextRange = Format((time - Now()), "hh:mm:ss")
Loop
End Sub
I see the solution being something like:
1. An entirely different way to pause a countdown with VBA
2. A way to make this countdown timer receive input in the format of hh:mm:ss
3. A way to convert the hh:mm:ss format back into seconds integer
Any of these things would effectively fix my problem.
Thank you for your consideration!