support

Wednesday 23 September 2015

cara membuat stopwatch dengan VB_net

Pagi semua, kali ini saya akan membahas tentang cara membuat stopwatch dengan menggunakan VB net,untuk pemula VB saja, nah bagaimana caranya..??yuk kita bahas...

pertama., buat desain ikon VB net anda seperti gambar di bawah ini,

 tentukan nama nya sesuai dengan seperti di gambar, agar coding yang saya bagikan berhasil dengan nama yang telah kamu tentuin,... sudah taukan caranya..??  kalau begitu ini Program codingnya...

Koding Program Stopwatch :
Public Class Form_StopWatch

    Sub Rancang_tabel()
        With LV
            .Columns.Add("Waktu", 180, HorizontalAlignment.Center)
            .View = View.Details
            .GridLines = True
            .FullRowSelect = True
        End With
    End Sub
    Sub Masuk_tabel()
        Dim masuk As New ListViewItem
        With masuk
            .Text = jam.Text & " : " & menit.Text & " : " & detik.Text & " : " & mili_detik.Text
            LV.Items.Add(masuk)
        End With
    End Sub

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        Mili_Detik.Text = Val(Mili_Detik.Text) + 1
        If Microsoft.VisualBasic.Len(Mili_Detik.Text) = 1 Then
            Mili_Detik.Text = "0" & Mili_Detik.Text
        End If
        If Mili_Detik.Text = "10" Then
            Mili_Detik.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 = "10" 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 = "10" Then
            Menit.Text = "00"
            Jam.Text = Val(Jam.Text) + 1
            If Microsoft.VisualBasic.Len(Menit.Text) = 1 Then
                Jam.Text = "0" & Jam.Text
            End If
        End If
    End Sub

    Private Sub BStart_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BStart.Click
        Mili_Detik.Text = "00"
        Detik.Text = "00"
        Menit.Text = "00"
        Jam.Text = "00"
        BStart.Enabled = False
        BRecord.Enabled = True
        BStop.Enabled = True
        Timer1.Start()
    End Sub

    Private Sub BStop_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BStop.Click
        Timer1.Stop()
        BRecord.Enabled = False
        BStart.Enabled = True
    End Sub

    Private Sub Form_StopWatch_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Rancang_tabel()
    End Sub

    Private Sub Keluar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Keluar.Click
        Dim x As String
        x = MsgBox("Anda Ingin Keluar?", MsgBoxStyle.YesNo, "Stopwach")
        If x = vbYes Then
            Me.Close()
        Else
            Me.Focus()
        End If
    End Sub

    Private Sub BRecord_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BRecord.Click
        Masuk_tabel()
    End Sub

End Class

Selamat mencoba, apabila ada kesalahan dapat berkomentar di kolom komentar dengan sopan, Trimakasih Telah berkunjung... :) salam Sirait.

0 comments:

Post a Comment

luvne.com resepkuekeringku.com desainrumahnya.com yayasanbabysitterku.com