[RESOLVED] Help using VB6 Timer, Countdown Scenario
Hey guys if theres anyone who can help, i need some advice on this:
I have 3 text boxes where the user can input values of seconds, minutes and hours. I need to find a way to use the timer to output the remaining time in hours left, minutes left and seconds left into the caption bar once activated. This will shut down the PC when the time has expired. Here's useful bits of coding i have at the moment, I'm sure i'm just missing something really simple but its doing my head in!
Code:
Private Sub startTimer()
intCnt = 0
totTime = 0
rHours = 0
rMins = 0
rSeconds = 0
hours = Val(txtHours) 'gets the bizz
mins = Val(txtMins)
seconds = Val(txtSecs)
Call workTotTime
rHours = hours
rMins = mins
rSeconds = seconds
Timer1.Enabled = True
End Sub
Private Sub workTotTime()
'works it out here
totTime = (60 * 60 * hours) + (60 * mins) + seconds
End Sub
Private Sub Timer1_Timer()
frmTimer.Caption = totTime - intCnt & " Seconds Until Shutdown"
intCnt = intCnt + 1
If intCnt > totTime Then
Timer1.Enabled = False
frmTimer.Caption = "Shutting Down"
Shell "Shutdown -s -t 00"
End If
End Sub
HTML Code:
<a href=http://myspace.com/kaykorbisskit><img src=http://www.divshare.com/img/2999859-282.JPG alt=MyProblem Height=720 Width=960></a>
http://www.divshare.com/img/2999859-282.JPG
Re: Help using VB6 Timer, Countdown Scenario
Code:
seconds = totTime - intCnt
minutes = seconds \ 60
seconds = seconds Mod 60
hours = minutes \ 60
minutes = minutes Mod 60
frmTimer.Caption = hours & ":" & minutes & ":" & seconds & " Until Shutdown"
Hope this helps.
Re: Help using VB6 Timer, Countdown Scenario
Omg thankyou so much it works :D
I knew it was something small and simple like that, I've never heard of Mod before, what uses does it have?
Do i rate you brilliant now?
Sorry but im new lol
Re: [RESOLVED] Help using VB6 Timer, Countdown Scenario
Mod is the remainder of a division. 7 mod 2 = 1; 10 mod 7 = 3 and so forth. It can be quite useful at times.