Hey there!
I'm making a break timing device for work (so I can be more aware of how long I'm taking on my breaks. I'm bad at keeping track.) If someone could help me out, it would be greatly appreciated.
What the program does:
- After I click "break" it Counts down from 15 minutes.
- Once the timer hits zero, it counts back up (in red text)
What I Need:
- As of right now, it just tells me how many minutes are left. I need to find out if/how I can display it by the second. (example: 15:00, 14:59, 14:58, 14:57, etc. right down to 0:00. Instead of just "15 Minutes, 14 minutes, etc) How would I do this??
This is the code I have so far:
Option Explicit
Dim StartTime As Date
Dim BreakTime As Long
Private Sub cmdBreak_Click()
cmdbreak.Enabled = False
cmdImBack.Enabled = True
StartTime = Now()
BreakTime = 1
Timer1.Enabled = False
Timer1.Interval = 5000
Timer1.Enabled = True
Timer1_Timer
End Sub
Private Sub cmdImBack_Click()
cmdImBack.Enabled = False
Timer1.Enabled = False
cmdbreak.Enabled = True
Text1.Text = ""
End Sub
Private Sub Form_Load()
cmdbreak.Enabled = True
cmdImBack.Enabled = False
Text1.Text = ""
End Sub
Private Sub Timer1_Timer()
Dim MinutesGone As Long
MinutesGone = DateDiff("n", StartTime, Now())
If MinutesGone < BreakTime Then
With Text1
.Text = (BreakTime - MinutesGone) & _
" mins"
.ForeColor = vbBlack
End With
Else
With Text1
.Text = "-" & (MinutesGone - BreakTime)
.ForeColor = vbRed
End With
End If
End Sub