Pada TUTORIAL kali ini akan dibahas mengenai Cara Membuat Aplikasi Shut Down Komputer Otomatis Dengan Timer
Berikut langkahnya :
Berikut langkahnya :
Form1 diatas terdapat :
Frame1
Frame2
Frame3
Option1
Option2
Option3
Combo1
Combo2
Combo3
Command1
Command2
Command3
Label1
Timer1
Frame1
Frame2
Frame3
Option1
Option2
Option3
Combo1
Combo2
Combo3
Command1
Command2
Command3
Label1
Timer1
- Kemudian ubah caption nya menjadi seperti ini
- Kemudian masukan koding dibawah ini :
Option Explicit
Dim c As String
Dim h, m, s As Integer
Private Sub KondisiAwal()
Label1.Caption = "Waktu belum di setting..."
Frame1.Enabled = True
Frame2.Enabled = True
Option1.Value = False
Option2.Value = False
Option3.Value = False
Command1.Enabled = True
Command2.Enabled = False
Combo1.Clear
Combo2.Clear
Combo3.Clear
For h = 0 To 59
Combo1.AddItem h
Combo2.AddItem h
Combo3.AddItem h
Next h
Timer1.Enabled = False
Me.Caption = "TIME OUT - Www.Ruchasta.Blogspot.Com"
End Sub
Private Sub Command2_Click()
If MsgBox("Yakin Akan Di Stop ?", vbYesNo, "Informasi Untuk Anda") = vbYes Then
Call KondisiAwal
End If
End Sub
Private Sub Command1_Click()
If (Combo1.Text <> "" And Combo2.Text <> "" And Combo3.Text <> "") And (Option1.Value Or Option2.Value Or Option3.Value) Then
If Option1.Value Then
c = "LOG OFF"
ElseIf Option2.Value Then
c = "RESTART"
Else
c = "SHUT DOWN"
End If
Timer1.Enabled = Not Timer1.Enabled
h = Val(Combo1.Text)
m = Val(Combo2.Text)
s = Val(Combo3.Text)
Command1.Enabled = False
Command2.Enabled = True
Frame1.Enabled = False
Frame2.Enabled = False
Else
MsgBox "Pastikan Pilihan - Jam, Menit dan Detik Terisi.", vbExclamation, "Informasi Untuk Anda"
End If
End Sub
Private Sub Command3_Click()
ShellExecute Me.hwnd, "Open", "http://ruchasta.blogspot.com/", vbNullString, vbNullString, 3
If Command2.Enabled = True Then
MsgBox "Silahkan Tekan Tombol STOP Terlebih Dahulu", vbInformation, "Informasi Untuk Anda"
Else
End
End If
End Sub
Private Sub Form_Load()
Call KondisiAwal
End Sub
Private Sub Form_Unload(Cancel As Integer)
If MsgBox("Anda Yakin Akan Keluar ?", vbYesNo, "Informasi Untuk Anda") <> vbYes Then
Cancel = 1
Me.WindowState = 1
End If
End Sub
Private Sub Timer1_Timer()
Label1.Caption = "Komputer ini akan " & c & " Otomatis setelah : " & Format(h, "00:") & Format(m, "00:") & Format(s, "00")
Me.Caption = Right(Label1.Caption, 8) + " Www.Ruchasta.Blogspot.Com"
If h = 0 And m = 0 And s = 0 Then
If c = "LOG OFF" Then
Shell "shutdown -l"
ElseIf c = "RESTART" Then
Shell "shutdown -s -t 00"
Else
Shell "shutdown -s -t 00"
End If
End
End If
If s = 0 Then
If m = 0 And h <> 0 Then
h = h - 1
m = 60
End If
m = m - 1
s = 60
End If
s = s - 1
End Sub
- Kemudian Jalankan aplikasinya
0 komentar:
Post a Comment