Aplikasi Stopwatch
Cara Membuat Stopwatch dengan Visual Studio C# 2010
Nama : Ahmad Farhan Zuhdi
NIM : 13141008
Kelas : 13.6A.37 (BSI PEMUDA)
Tugas Network Programming II
Gambar 1.1. Display Stopwatch
Gambar 1.2. Tampilan START Stopwatch
Gambar 1.3. Tampilan STOP Stopwatch
Gambar 1.4. Tampilan RESET Stopwatch
Coding Project :
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace stopwatchh
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
int hour, min, sec, ms = 0;
private void button2_Click(object sender, EventArgs e)
{
timer1.Stop();
}
private void button1_Click(object sender, EventArgs e)
{
timer1.Start();
}
private void timer1_Tick(object sender, EventArgs e)
{
label1.Text = hour + ":" + min + ":" + sec + ":" + ms.ToString();
ms++;
if (ms > 10)
{
sec++;
ms = 0;
}
else
{
ms++;
}
if (min > 60)
{
hour++;
min = 0;
}
}
private void button3_Click(object sender, EventArgs e)
{
hour = 0;
min = 0;
sec = 0;
ms = 0;
label1.Text = 0 + ":" + 0 + ":" + 0 + ":" + 0;
}
}
}
0 komentar:
Posting Komentar