Contoh Program Sederhana Membuat Aplikasi Stopwatch
komponen yang diperlukan :
1. label 3 : Menit
Detik
Milidetik
2. textbox 3 : xmili
xdetik
xmenit
3. Timer : pengaturan kecepatan terletak pada propertis interval
4. button 2 : cmdstart
cmdstop
kemudian pelajari listing codenya dibawah ini :
Private Sub CmdStart_Click()
Xmili.Caption = “00″
xdetik.Caption = “00″
xmenit.Caption = “00″
Timer1.Enabled = True
CmdStart.Enabled = False
CmdStop.Enabled = True
End Sub
komponen yang diperlukan :
1. label 3 : Menit
Detik
Milidetik
2. textbox 3 : xmili
xdetik
xmenit
3. Timer : pengaturan kecepatan terletak pada propertis interval
4. button 2 : cmdstart
cmdstop
kemudian pelajari listing codenya dibawah ini :
Private Sub CmdStart_Click()
Xmili.Caption = “00″
xdetik.Caption = “00″
xmenit.Caption = “00″
Timer1.Enabled = True
CmdStart.Enabled = False
CmdStop.Enabled = True
End Sub
Private Sub CmdStop_Click()
Timer1.Enabled = False
CmdStart.Enabled = True
CmdStop.Enabled = False
End Sub
Timer1.Enabled = False
CmdStart.Enabled = True
CmdStop.Enabled = False
End Sub
Private Sub Form_Load()
Timer1.Enabled = False
CmdStop.Enabled = False
End Sub
Timer1.Enabled = False
CmdStop.Enabled = False
End Sub
Private Sub Timer1_Timer()
Xmili.Caption = Val(Xmili.Caption) + 1
If Len(Xmili.Caption) = 1 Then Xmili.Caption = “0″ & Xmili.Caption
If Xmili.Caption = “60″ Then
Xmili.Caption = “00″
xdetik.Caption = Val(xdetik.Caption) + 1
If Len(xdetik.Caption) = 1 Then xdetik.Caption = “0″ & xdetik.Caption
End If
If xdetik.Caption = “60″ Then
xdetik.Caption = “00″
xmenit.Caption = Val(xmenit.Caption) + 1
If Len(xmenit.Caption) = 1 Then xmenit.Caption = “0″ & xmenit.Caption
End If
End Sub
Xmili.Caption = Val(Xmili.Caption) + 1
If Len(Xmili.Caption) = 1 Then Xmili.Caption = “0″ & Xmili.Caption
If Xmili.Caption = “60″ Then
Xmili.Caption = “00″
xdetik.Caption = Val(xdetik.Caption) + 1
If Len(xdetik.Caption) = 1 Then xdetik.Caption = “0″ & xdetik.Caption
End If
If xdetik.Caption = “60″ Then
xdetik.Caption = “00″
xmenit.Caption = Val(xmenit.Caption) + 1
If Len(xmenit.Caption) = 1 Then xmenit.Caption = “0″ & xmenit.Caption
End If
End Sub
Tidak ada komentar:
Posting Komentar