ThomasLafferty
Instructor
I have a break timer for PowerPoint which uses the timer function to count backwards in the slide title.
The problem is that the display is in seconds:
300, 399, 398
Instead of time format:
05:00, 04:59, 04:58
The problem is that the variable I am using calculates the difference between start time using the timer function. This returns a number for the start time in terms of seconds from midnight, which is not an actual time. It is numeric. When I try to format it as time Format(myString,"Medium Time") for example, it displays 12:00 AM and never counts down.
Here's the code I am working with:
The problem is that the display is in seconds:
300, 399, 398
Instead of time format:
05:00, 04:59, 04:58
The problem is that the variable I am using calculates the difference between start time using the timer function. This returns a number for the start time in terms of seconds from midnight, which is not an actual time. It is numeric. When I try to format it as time Format(myString,"Medium Time") for example, it displays 12:00 AM and never counts down.
Here's the code I am working with:
Code:
'**************Global Declarations**************
Dim DisplayMinutes, StartTime, StopTime, FrmtString
Public Sub BreakLengthInMinutes_Change()
DisplayMinutes = Me.BreakLengthInMinutes.Value
If DisplayMinutes < 10 Then
DisplayMinutes = "0" & DisplayMinutes & ":00"
Else
DisplayMinutes = DisplayMinutes & ":00"
End If
With Shapes.Title.TextFrame.TextRange
.Text = DisplayMinutes
End With
End Sub
Public Sub StartTimer_Button_Click()
If Me.StartTimer_Button.Caption = "End = Ctrl + Break" Then
Me.StartTimer_Button.Caption = "Start Timer"
End If
On Error GoTo Trap
StartTime = Timer
StopTime = StartTime + Me.BreakLengthInMinutes * 60 'returns total seconds for countdown
Do While Timer < StopTime
DoEvents
DisplayMinutes = CLng(StopTime) - CLng(Timer)
FrmtString = Format(DisplayMinutes, "Medium Time")
'*****************Need formatting for time display here*******************
Shapes.Title.TextFrame.TextRange.Text = FrmtString
Loop
GoTo LastInstruction
Trap:
Err = 0
Me.StartTimer_Button.Caption = "Start Timer"
Exit Sub
LastInstruction:
MsgBox "Break has ended.", vbInformation, "Time's Up!"
Me.StartTimer_Button.Caption = "Start Timer"
End Sub