Pages

Kamis, 12 Maret 2009

cara membuat stopwatch

Cara membuat stopwatch :

Item yang dibutuhkan adalah :

- Command1 sebagai “MULAI”
- Command2 sebagai “PAUSE”
- Command3 sebagai “”ATUR ULANG”
- 1 Buah timer dengan interval 10, left 960, top 840



Dengan Listing Program :
Dim TotalTenthDetik, TotalDetik, TenthDetik, Detik, _
Menit, jam As Integer
Dim jam1 As String



Private Sub Command1_Click()
'inisialisasi total sepersepuluh detik
TotalTenthDetik = -1
'Aktifkan timer
Timer1.Enabled = True

End Sub


Private Sub Command2_Click()
'memutar atau menghentikan timer kembali
Timer1.Enabled = Not Timer1.Enabled

End Sub

Private Sub Command3_Click()
Text1.Text = ""
Text1.SetFocus

End Sub

Private Sub Timer1_Timer()
TotalTenthDetik = TotalTenthDetik + 1
TenthDetik = TotalTenthDetik Mod 10
TotalDetik = Int(TotalTenthDetik / 10)
Detik = TotalDetik Mod 60
If Len(Detik) = 1 Then
Detik = "0" & Detik
End If

Menit = Int(TotalDetik / 60) Mod 100
If Len(Menit) = 1 Then
Menit = "0" & Menit
End If
jam = Int(TotalDetik / 3600)
If jam < 9 Then
jam1 = "0" & jam
End If

Text1 = jam1 & ":" & Menit & ":" & Detik & ":" _
& TenthMenit & ""

End Sub

1 komentar:

g312m4nt.blogspot.com mengatakan...

DULU UDAH ADA POST NYA, TAPI LUPA URL NYA, MAKASI