Desain Form Seperti di Bawah ini:

Lalu tambahkan Timer ambil dari Toolbox
Listing Program Seperti di bawah ini:
Public Class Form2
Sub tabel()
With waktu
.Columns.Add("Waktu", 115, HorizontalAlignment.Center)
.GridLines = True
.View = View.Details
End With
End Sub
Private Sub start_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles start.Click
milidetik.Text = "00"
detik.Text = "00"
menit.Text = "00"
jam.Text = "00"
Timer1.Start()
start.Enabled = False
record.Enabled = True
cmdstop.Enabled = True
End Sub
Private Sub stop__Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdstop.Click
Timer1.Stop()
start.Enabled = True
record.Enabled = True
cmdstop.Enabled = False
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
tabel()
End Sub
Sub isi()
Dim x As New ListViewItem
With x
.Text = jam.Text & ":" & menit.Text & ":" & detik.Text & ":" & milidetik.Text
waktu.Items.Add(x)
End With
End Sub
Private Sub Record_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles record.Click
isi()
End Sub
Private Sub Timer1_Tick_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
milidetik.Text = Val(milidetik.Text) + 6
If Microsoft.VisualBasic.Len(milidetik.Text) = 1 Then
milidetik.Text = "0" & milidetik.Text
End If
If milidetik.Text = "60" Then
milidetik.Text = "00"
detik.Text = Val(detik.Text) + 1
If Microsoft.VisualBasic.Len(detik.Text) = 1 Then
detik.Text = "0" & detik.Text
End If
End If
If detik.Text = "60" Then
detik.Text = "00"
menit.Text = Val(menit.Text) + 1
If Microsoft.VisualBasic.Len(menit.Text) = 1 Then
menit.Text = "0" & menit.Text
End If
End If
If menit.Text = "60" Then
menit.Text = "00"
jam.Text = Val(jam.Text) + 1
If Microsoft.VisualBasic.Len(jam.Text) = 1 Then
jam.Text = "0" & jam.Text
End If
End If
End Sub
End Class
Hasil program seperti dibawah ini:
Selamat Mencoba????
Lalu tambahkan Timer ambil dari Toolbox
Listing Program Seperti di bawah ini:
Public Class Form2
Sub tabel()
With waktu
.Columns.Add("Waktu", 115, HorizontalAlignment.Center)
.GridLines = True
.View = View.Details
End With
End Sub
Private Sub start_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles start.Click
milidetik.Text = "00"
detik.Text = "00"
menit.Text = "00"
jam.Text = "00"
Timer1.Start()
start.Enabled = False
record.Enabled = True
cmdstop.Enabled = True
End Sub
Private Sub stop__Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdstop.Click
Timer1.Stop()
start.Enabled = True
record.Enabled = True
cmdstop.Enabled = False
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
tabel()
End Sub
Sub isi()
Dim x As New ListViewItem
With x
.Text = jam.Text & ":" & menit.Text & ":" & detik.Text & ":" & milidetik.Text
waktu.Items.Add(x)
End With
End Sub
Private Sub Record_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles record.Click
isi()
End Sub
Private Sub Timer1_Tick_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
milidetik.Text = Val(milidetik.Text) + 6
If Microsoft.VisualBasic.Len(milidetik.Text) = 1 Then
milidetik.Text = "0" & milidetik.Text
End If
If milidetik.Text = "60" Then
milidetik.Text = "00"
detik.Text = Val(detik.Text) + 1
If Microsoft.VisualBasic.Len(detik.Text) = 1 Then
detik.Text = "0" & detik.Text
End If
End If
If detik.Text = "60" Then
detik.Text = "00"
menit.Text = Val(menit.Text) + 1
If Microsoft.VisualBasic.Len(menit.Text) = 1 Then
menit.Text = "0" & menit.Text
End If
End If
If menit.Text = "60" Then
menit.Text = "00"
jam.Text = Val(jam.Text) + 1
If Microsoft.VisualBasic.Len(jam.Text) = 1 Then
jam.Text = "0" & jam.Text
End If
End If
End Sub
End Class
Hasil program seperti dibawah ini:
Selamat Mencoba????
Tidak ada komentar:
Posting Komentar