Made this for Cool372.
Basically gives you the option of:
Restarting.
Shutdown.
Logoff
Under a certain amount of time. Max time limit it will countdown from is 100 hours 40 minutes and 39 seconds. You can change that if you feel its needed.
Project is Attached.
Source:
Basically gives you the option of:
Restarting.
Shutdown.
Logoff
Under a certain amount of time. Max time limit it will countdown from is 100 hours 40 minutes and 39 seconds. You can change that if you feel its needed.
Project is Attached.
Source:
Code:
Private Sub cmdEnterTime_Click()
If cmdEnterTime.Caption = "Enter Time" Then
lblDisplay = "00:00:00"
cmdEnterTime.Caption = "Set Time"
txtHr.Visible = True
txtMin.Visible = True
txtSec.Visible = True
txtHr.SetFocus
Else
Dim Hrs As String, Mins As String, Secs As String
If Val(txtHr) = 0 Then
Hrs = "00"
Else
Hrs = Val(txtHr)
End If
If Val(txtMin) >= "60" Then
Mins = Val(txtMin) - 60
Hrs = Val(Hrs) + 1
Else
Mins = Val(txtMin)
End If
If Val(txtSec) >= "60" Then
Secs = Val(txtSec) - 60
Mins = Val(Mins) + 1
Else
Secs = Val(txtSec)
End If
lblDisplay = IIf(Val(Hrs) < 10, "0" & Val(Hrs), Hrs) & ":" & IIf(Val(Mins) < 10, "0" & Val(Mins), Mins) & ":" & IIf(Val(Secs) < 10, "0" & Val(Secs), Secs)
cmdEnterTime.Caption = "Enter Time"
txtHr.Visible = False
txtMin.Visible = False
txtSec.Visible = False
End If
End Sub
Private Sub cmdStart_Click()
If cmdEnterTime.Caption = "Set Time" Or lblDisplay = "00:00:00" Then
MsgBox "Please set an amount of time to count down.", vbCritical, "No Time Set"
Exit Sub
End If
If cmdStart.Caption = "S T A R T" Then
cmdStart.Caption = "S T O P"
cmdEnterTime.Enabled = False
tmrShutdown.Enabled = True
Else
cmdStart.Caption = "S T A R T"
cmdEnterTime.Enabled = True
tmrShutdown.Enabled = False
lblDisplay = "00:00:00"
End If
End Sub
Private Sub tmrShutdown_Timer()
Dim Hrs As Integer, Mins As Integer, Secs As Integer
Hrs = Val(Split(lblDisplay, ":")(0))
Mins = Val(Split(lblDisplay, ":")(1))
Secs = Val(Split(lblDisplay, ":")(2))
If Hrs = "0" And Mins = "0" And Secs = "0" Then
tmrShutdown.Enabled = False
cmdEnterTime.Enabled = True
lblDisplay = "00:00:00"
ShutDownType
Exit Sub
End If
If Secs = "0" Then
If Mins = "0" Then
If Not Hrs = "0" Then
Hrs = Hrs - 1
End If
Mins = "59"
Else
Mins = Mins - 1
End If
Secs = "59"
Else
Secs = Secs - 1
End If
lblDisplay = IIf(Hrs < 10, "0" & Hrs, Hrs) & ":" & IIf(Mins < 10, "0" & Mins, Mins) & ":" & IIf(Secs < 10, "0" & Secs, Secs)
End Sub
Private Sub ShutDownType()
If Option1(0).Value = True Then
Shell "Shutdown -s"
ElseIf Option1(1).Value = True Then
Shell "Shutdown -l"
ElseIf Option1(2).Value = True Then
Shell "Shutdown -r"
End If
End Sub




