Kali ini saya akan share kepada pembaca blog ini bagaimana cara membuat sebuah hitungan mundur dengan menggunakan visual basic 60.Bagi Anda yang penasaran bagaimana cara membuatnya ikuti lankah-langkah berikut dibawah ini:
1. Buka form Visual Basic Anda
2. Tanamkan beberapa Label, 1 Timer, 4 Comandbutton, 1 Frame (optional) dan 3 TextBox
3. Atur peoperti masing-masing
Label1 dan TextBox Captionnya biarkan saja
Command1 Caption Star
Command2 Caption Atur
Command3 Caption Stop
command4 Caption Batal
Timer1 Enabled =False Interval =1000
4. Desainlah seperti gambar dibawah ini:
5. Lalu buka jendela kode dengan F7 copy-paste kode dibawah bagian General-Declaratin
Dim jam As Integer
Dim menit As Integer
Dim detik As Integer
Private Sub Command1_Click()
jam = Text1.Text
menit = Text2.Text
detik = Text3.Text
Label1.Caption = Format(jam, "00") & ":" & Format(menit, "00") & ":" & Format(detik, "00")
Timer1.Enabled = True
Command1.Enabled = False
Command3.Enabled = True
End Sub
Private Sub Command2_Click()
If Command2.Caption = "Atur" Then
Command2.Caption = "Save"
Command4.Enabled = True
Text1.Text = "00:00:00"
Text2.Text = "00:00:00"
Text3.Text = "00:00:00"
Text1.Enabled = True
Text2.Enabled = True
Text3.Enabled = True
Text1.SetFocus
Else
If Command2.Caption = "Save" Then
If Text1.Text = "00" And Text2.Text = "00" And Text3.Text = "00" Then
MsgBox "Waktu belum di atur", vbCritical, "Error Input"
Text1.SetFocus
Else
Command2.Enabled = False
Command1.Enabled = True
Command2.Caption = "Atur"
Command4.Enabled = False
Text1.Enabled = False
Text2.Enabled = False
Text3.Enabled = False
End If
End If
End If
End Sub
Private Sub Command3_Click()
Timer1.Enabled = False
Command2.Enabled = True
Command3.Enabled = False
Text1.Text = "00"
Text2.Text = "00"
Text3.Text = "00"
End Sub
Private Sub Command4_Click()
Command2.Caption = "Atur"
Label1.Caption = "00:00:00"
Command1.Enabled = False
Command3.Enabled = False
Command4.Enabled = False
Text1.Enabled = False
Text2.Enabled = False
Text3.Enabled = False
Text1.Text = "00"
Text2.Text = "00"
Text3.Text = "00"
Command2.SetFocus
End Sub
Private Sub Form_Load()
Label1.Caption = "00:00:00"
Command1.Enabled = False
Command3.Enabled = False
Command4.Enabled = False
Text1.Enabled = False
Text2.Enabled = False
Text3.Enabled = False
Text1.Text = "00"
Text2.Text = "00"
Text3.Text = "00"
End Sub
Private Sub Timer1_Timer()
detik = detik - 1
If detik < 0 Then
detik = 59
menit = menit - 1
Else
If menit < 0 Then
menit = 59
jam = jam - 1
End If
End If
Label1.Caption = Format(jam, "00") & ":" & Format(menit, "00") & ":" & Format(detik, "00")
If jam = 0 And menit = 0 And detik = 0 Then
Timer1.Enabled = False
MsgBox "Waktu Sudah Habis", vbInformation, "Perhatian"
Command1.Enabled = False
Command3.Enabled = False
Command2.Enabled = True
Text1.Text = "00"
Text2.Text = "00"
Text3.Text = "00"
End If
End Sub
6. Simpan hasil pekerjaan Anda, dan jalankan program
Selamat Mencoba semoga berhasil....!!!!
Aplikasi Hitung Mundur |
1. Buka form Visual Basic Anda
2. Tanamkan beberapa Label, 1 Timer, 4 Comandbutton, 1 Frame (optional) dan 3 TextBox
3. Atur peoperti masing-masing
Label1 dan TextBox Captionnya biarkan saja
Command1 Caption Star
Command2 Caption Atur
Command3 Caption Stop
command4 Caption Batal
Timer1 Enabled =False Interval =1000
4. Desainlah seperti gambar dibawah ini:
Form Desian |
5. Lalu buka jendela kode dengan F7 copy-paste kode dibawah bagian General-Declaratin
Dim jam As Integer
Dim menit As Integer
Dim detik As Integer
Private Sub Command1_Click()
jam = Text1.Text
menit = Text2.Text
detik = Text3.Text
Label1.Caption = Format(jam, "00") & ":" & Format(menit, "00") & ":" & Format(detik, "00")
Timer1.Enabled = True
Command1.Enabled = False
Command3.Enabled = True
End Sub
Private Sub Command2_Click()
If Command2.Caption = "Atur" Then
Command2.Caption = "Save"
Command4.Enabled = True
Text1.Text = "00:00:00"
Text2.Text = "00:00:00"
Text3.Text = "00:00:00"
Text1.Enabled = True
Text2.Enabled = True
Text3.Enabled = True
Text1.SetFocus
Else
If Command2.Caption = "Save" Then
If Text1.Text = "00" And Text2.Text = "00" And Text3.Text = "00" Then
MsgBox "Waktu belum di atur", vbCritical, "Error Input"
Text1.SetFocus
Else
Command2.Enabled = False
Command1.Enabled = True
Command2.Caption = "Atur"
Command4.Enabled = False
Text1.Enabled = False
Text2.Enabled = False
Text3.Enabled = False
End If
End If
End If
End Sub
Private Sub Command3_Click()
Timer1.Enabled = False
Command2.Enabled = True
Command3.Enabled = False
Text1.Text = "00"
Text2.Text = "00"
Text3.Text = "00"
End Sub
Private Sub Command4_Click()
Command2.Caption = "Atur"
Label1.Caption = "00:00:00"
Command1.Enabled = False
Command3.Enabled = False
Command4.Enabled = False
Text1.Enabled = False
Text2.Enabled = False
Text3.Enabled = False
Text1.Text = "00"
Text2.Text = "00"
Text3.Text = "00"
Command2.SetFocus
End Sub
Private Sub Form_Load()
Label1.Caption = "00:00:00"
Command1.Enabled = False
Command3.Enabled = False
Command4.Enabled = False
Text1.Enabled = False
Text2.Enabled = False
Text3.Enabled = False
Text1.Text = "00"
Text2.Text = "00"
Text3.Text = "00"
End Sub
Private Sub Timer1_Timer()
detik = detik - 1
If detik < 0 Then
detik = 59
menit = menit - 1
Else
If menit < 0 Then
menit = 59
jam = jam - 1
End If
End If
Label1.Caption = Format(jam, "00") & ":" & Format(menit, "00") & ":" & Format(detik, "00")
If jam = 0 And menit = 0 And detik = 0 Then
Timer1.Enabled = False
MsgBox "Waktu Sudah Habis", vbInformation, "Perhatian"
Command1.Enabled = False
Command3.Enabled = False
Command2.Enabled = True
Text1.Text = "00"
Text2.Text = "00"
Text3.Text = "00"
End If
End Sub
6. Simpan hasil pekerjaan Anda, dan jalankan program
Selamat Mencoba semoga berhasil....!!!!
0 Response to "Cara Membuat Aplikasi Hitung Mundur di VB 6.0"
Post a Comment