Tutorial Membuat Aplikasi StopWatch Pada Visual Studio 2010
Kali ini saya akan membaut tutorial sederhana, yaitu Aplikasi StopWatch Menggunakan Visual Studio 2010.
Mohon maaf ya, gambar tutorialnya belum di upload, tapi untuk tutorial lengkapnya bisa didownload melalui link yang dibawah:
1. 1. Buka Visual
Studio 2010, New Project è Beri Nama Login è OK
2. 2. Ubah
Properti pada Form1 seperti gambar dibawah ini.
3. 3. Kemudian
tambahkan 3 tombol Button, 1 label:
Button1 è Start, Properti è Text (Start),
Name (btnStart)
Button2 è Stop , Propertiè Text (Stop),
Name (btnStop)
Button3 è Reset , PropertièText
(Reset), Name (btnReset)
Label1 è
Properti è Text(Kosongkan), Name lblTime)
4. 4. Tambahkan
“Timer1” dari Toolbox
5. 5. Ketika
program ini dibawah:
Public Class StopWatch
Inherits System.Windows.Forms.Form
Dim Mili,
Sec, Min, hr As Integer
Dim
Countr As Integer
End Class
|
6. 6. Double Klik
Form “StopWatch”, ketika progam Berikut:
Private Sub
StopWatch_Load(ByVal sender As System.Object,
ByVal e As
System.EventArgs) Handles
MyBase.Load
Mili = 0
Sec = 0
Min = 0
hr = 0
End Sub
|
7. 7. Program “Start”
Double Klik “Start”, selanjutnya ketikan program berikut:
Private Sub
btnStart_Click(ByVal sender As System.Object,
ByVal e As
System.EventArgs) Handles
btnStart.Click
Timer1.Enabled = True
End Sub
|
8. 8. Program “Stop”
Double Klik “Stop”, ketikan program ini:
Private Sub btnStop_Click(ByVal
sender As System.Object,
ByVal e As
System.EventArgs) Handles
btnStop.Click
Timer1.Enabled = False
End Sub
|
9. 9. Program
“Reset”
Double Klik “Reset”, ketikan program ini:
Private Sub
btnReset_Click(ByVal sender As System.Object,
ByVal e As
System.EventArgs) Handles
btnReset.Click
Dim
mYes_No As String
= MsgBox("Kamu Ingin Reset The Timer ?",
vbYesNo)
If
mYes_No = vbYes Then
Mili = 0
Sec = 0
Min = 0
hr = 0
lblTime.Text = ""
Timer1.Enabled = False
End If
End Sub
|
1 10.Double Klik
“Timer1” Ketikan Program berikut :
Private Sub Timer1_Tick(ByVal
sender As System.Object,
ByVal e As
System.EventArgs) Handles
Timer1.Tick
Dim
Mili2, Sec2, Min2, hr2 As String
Countr = Countr + 1
Mili2 = Countr
If
Countr = 10 Then
Sec = Sec + 1
Countr = 0
End If
If
Sec = 60 Then
Min = Min + 1
Sec = 0
End If
If
Min = 60 Then
hr = hr + 1
Min = 0
End If
Sec2 = Format(Val(Sec), "00")
Min2 = Format(Val(Min), "00")
hr2 = Format(Val(hr), "00")
lblTime.Text = hr2 & ":" & Min2 & ":" & Sec2 & ":" & Mili2
End Sub
|
1 11. Akhirnya
Program ini selesai juga, “RUN”
1 12. Setelah di
Run, Maka hasilnya awalnya seperti ini:
1 13. Tutorial Stop
Watch Selesai.
Download:
Artikel Lain :
Semoga
Bermanfaat! Mohon Di Like FanPage-nya Ya! Thanks.
0 Komentar:
Posting Komentar