Membuat STOPWATCH Dengan VB
6.0
Pada Latihan VB 6.0 kali ini akan dibahas bagaimana cara
membuat Stopwatch dengan VB 6.0
Buka Aplikasi VB 6.0 anda
Buatlah Design form seperti gambar dibawah ini :
Berikut langkahnya :
Buka Aplikasi VB 6.0 anda
Buatlah Design form seperti gambar dibawah ini :
Yang harus ada pada Design form diatas adalah :
Label1
Label2
Label3
Command1
Command2
Command3
Timer1
Jika sudah membuat Design diatas, Klik Timer1
Label1
Label2
Label3
Command1
Command2
Command3
Timer1
Jika sudah membuat Design diatas, Klik Timer1
Ubah pada properties Timer1 seperti gambar diatas
Kemudian masukan Koding dibawah ini :
Kemudian masukan Koding dibawah ini :
Private Sub Command1_Click()
Label3.Caption = "00"
Label2.Caption = "00"
Label1.Caption = "00"
Timer1.Enabled = True
Command1.Enabled = False
Command2.Enabled = True
End Sub
Private Sub Command2_Click()
Timer1.Enabled = False
Command1.Enabled = True
Command2.Enabled = False
End Sub
Private Sub Command3_Click()
End
End Sub
Private Sub Form_Load()
Timer1.Enabled = False
Command2.Enabled = False
Label1.Caption = "00"
Label2.Caption = "00"
Label3.Caption = "00"
End Sub
Private Sub Timer1_Timer()
Label3.Caption = Val(Label3.Caption) + 1
If Len(Label3.Caption) = 1 Then Label3.Caption = "0" & Label3.Caption
If Label3.Caption = "60" Then
Label3.Caption = "00"
Label2.Caption = Val(Label2.Caption) + 1
If Len(Label2.Caption) = 1 Then Label2.Caption = "0" & Label2.Caption
End If
If Label2.Caption = "60" Then
Label2.Caption = "00"
Label1.Caption = Val(Label1.Caption) + 1
If Len(Label1.Caption) = 1 Then Label1.Caption = "0" & Label1.Caption
End If
End Sub
Label3.Caption = "00"
Label2.Caption = "00"
Label1.Caption = "00"
Timer1.Enabled = True
Command1.Enabled = False
Command2.Enabled = True
End Sub
Private Sub Command2_Click()
Timer1.Enabled = False
Command1.Enabled = True
Command2.Enabled = False
End Sub
Private Sub Command3_Click()
End
End Sub
Private Sub Form_Load()
Timer1.Enabled = False
Command2.Enabled = False
Label1.Caption = "00"
Label2.Caption = "00"
Label3.Caption = "00"
End Sub
Private Sub Timer1_Timer()
Label3.Caption = Val(Label3.Caption) + 1
If Len(Label3.Caption) = 1 Then Label3.Caption = "0" & Label3.Caption
If Label3.Caption = "60" Then
Label3.Caption = "00"
Label2.Caption = Val(Label2.Caption) + 1
If Len(Label2.Caption) = 1 Then Label2.Caption = "0" & Label2.Caption
End If
If Label2.Caption = "60" Then
Label2.Caption = "00"
Label1.Caption = Val(Label1.Caption) + 1
If Len(Label1.Caption) = 1 Then Label1.Caption = "0" & Label1.Caption
End If
End Sub
kemudian jalankan Program anda



Tidak ada komentar:
Posting Komentar