fromStopwach |
Dim SW As New Stopwatch
'OnOff = 1 - jalan
'OnOff = 0 - mati
Dim OnOff As Byte = 1
Private Sub frmStopwatch_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed
OnOff = 0
SW.Stop()
OnOff = Nothing
End Sub
Private Sub Stopwatch_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
lblJam.Text = "00:00:00:.000"
lblSecond.Text = 0
lblStatus.Text = "-"
lblTanggal.Text = Today()
End Sub
Private Sub btnStart_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStart.Click
Dim detik As Integer = Nothing
OnOff = 1
SW.Start()
btnStop.Focus()
Do Until OnOff = 0
My.Application.DoEvents()
lblJam.Text = SW.Elapsed.ToString
detik = SW.ElapsedMilliseconds \ 1000
lblSecond.Text = detik
lblStatus.Text = SW.IsRunning.ToString
Loop
End Sub
Private Sub btnStop_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStop.Click
OnOff = 0
SW.Stop()
End Sub
Private Sub btnReset_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnReset.Click
Dim detik As Integer = Nothing
OnOff = 1
SW.Reset()
SW.Start()
btnStop.Focus()
Do Until OnOff = 0
My.Application.DoEvents()
lblJam.Text = SW.Elapsed.ToString
detik = SW.ElapsedMilliseconds \ 1000
lblSecond.Text = detik
lblStatus.Text = SW.IsRunning.ToString
Loop
End Sub
End Class
0 komentar:
Posting Komentar