If MsgBox("Are you sure ?", vbYesNo, "System Message") = vbYes Then
enable
Me.Caption = "TIME OUT"
End If
End Sub
Private Sub cmdexecute_Click()
If (Combo1.Text <> "" And Combo2.Text <> "" And Combo3.Text <> "") And (Option1.Value Or Option2.Value Or Option3.Value) Then
If Option1.Value Then 'same as of If Option1.Value=True Then
c = "log off"
ElseIf Option2.Value Then 'same as of ElseIf Option2.Value=True Then
c = "restart"
Else
c = "shutdown"
End If
h = Val(Combo1.Text)
m = Val(Combo2.Text)
s = Val(Combo3.Text)
enable
Else
MsgBox "Please fill up the following : Hour(s), Minute(s), Second(s) and also choose any of the following : Log Off, Restart and Shutdown.", vbExclamation, "System Message"
End If
End Sub
Private Sub Form_Load()
For h = 0 To 59
Combo1.AddItem h
Combo2.AddItem h
Combo3.AddItem h
Next h
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, x As Single, Y As Single)
Option1.ForeColor = vbBlack
Option2.ForeColor = vbBlack
Option3.ForeColor = vbBlack
End Sub
Private Sub Form_Unload(Cancel As Integer)
If MsgBox("Are you sure ?", vbYesNo, "System Message") <> vbYes Then
Cancel = 1
Me.WindowState = 1
End If
End Sub
Private Sub Option1_MouseMove(Button As Integer, Shift As Integer, x As Single, Y As Single)
Option1.ForeColor = vbBlue
End Sub
Private Sub Option2_MouseMove(Button As Integer, Shift As Integer, x As Single, Y As Single)
Option2.ForeColor = vbBlue
End Sub
Private Sub Option3_MouseMove(Button As Integer, Shift As Integer, x As Single, Y As Single)
Option3.ForeColor = vbBlue
End Sub
Private Sub Timer1_Timer()
Label2.Caption = "This computer will " & c & Chr(13) & " itself after : " & Format(h, "00:") & Format(m, "00:") & Format(s, "00")
Me.Caption = Right(Label2.Caption, 8)
If h = 0 And m = 0 And s = 0 Then
If c = "log off" Then
Shell "shutdown -l" 'This line will log off your computer
ElseIf c = "restart" Then
Shell "shutdown -r -t 00" 'This line will restart your computer
Else
Shell "shutdown -s -t 00" 'This line will shutdown your computer
End If
End 'I write End because sometimes the shell shutdown command is being delayed