Minggu, 26 Juni 2011

Program StopWatch Dengan Menggunakan VB

Stopwatch
Semoga Bermanfaat BAgi Anda

Private Sub Command1_Click()
    detik.Caption = "00"
    menit.Caption = "00"
    jam.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 Form_Load()
    Timer1.Enabled = False
    Command2.Enabled = False
End Sub

Private Sub Timer1_Timer()
   detik = detik + 1
    If Val(detik) > 59 Then
    detik = "00?"
    menit = Val(menit) + 1
    If Val(menit) > 59 Then
    'menit = "00?"
    jam = Val(jam) + 1
        If Val(jam) > 23 Then
    jam = "00"
        End If
End If
End If

  detik.Caption = Val(detik.Caption) + 1
If Len(detik.Caption) = 1 Then detik.Caption = "0" & detik.Caption
If detik.Caption = "60" Then
menit.Caption = "00"
menit.Caption = Val(menit.Caption) + 1
If Len(menit.Caption) = 1 Then menit.Caption = "0?" & menit.Caption
End If
If menit.Caption = "60" Then
'menit.Caption = "00?"
jam.Caption = Val(xmenit.Caption) + 1
If Len(jam.Caption) = 1 Then jam.Caption = "0?" & jam.Caption
End If

End Sub

Private Sub Timer2_Timer()
    Label1.Visible = Not Label1.Visible
    Label2.Visible = Not Label2.Visible
End Sub
Tekan F5 untuk menampilkan hasilnya.