As you might remember I posted a post a couple of days back regarding Timers.
The application that I'm making is a program that will restart the computer after a certain period of time. This can be done in one of two ways: Either when the coundown reaches 0, or when the clock reaches a specified time:
As you can see, on the right are hour/minute/second fields. When filled in and "Set" is activated, it will count down and when it gets to 0, restart the computer. This is working fine (You will notice in the source there is no restart code; I'm leaving that until right at the end. Currently it just gives a msgbox).
The problem that I now have is the right hand section: making it shut down at a certain date. With the countdown it was easy; just multiply the hour and minute boxes by 3600 and 60 respectively, and add all 3 together (to get the total in seconds) and just make the timer look to that variable.
The problem here is that I have 3 text boxes (on the right), dropping their entried into 3 "Date" type variables. I now need to somehow make those add together and generate a 24 hour time. That will then be stored, and when the system clock reaches the same as the stored 24hour "Time", activate the code.
HERE is a complete ZIP of the whole project. Below you can also see the whole source code used for the program. Here's an extract of my comments around the area that i'm discussing:
Code:
' I need a way to turn those 3 vars (NOT the I ones. the I ones are
' Just there to allow me to post the shutdown time to TSD)
' into a time on the 24 hour scale.
' From this I will calculate how long left until it reaches that time
' And set that information to "Time remaining until shutdown"
And here's the section of code itself:
Code:
NewHour = TimeH
NewMin = TimeM
NewSec = TimeS
NewHouri = TimeH
NewMini = TimeM
NewSeci = TimeS
' I need a way to turn those 3 vars (NOT the I ones. the I ones are
' Just there to allow me to post the shutdown time to TSD)
' into a time on the 24 hour scale.
' From this I will calculate how long left until it reaches that time
' And set that information to "Time remaining until shutdown"
TotalTime = NewHour + NewMin + NewSec
TSD = NewHouri & ":" & NewMini & ":" & NewSeci
Everything else within that part of the IF statement is the same as it is for the left section.