Stopwatch
CARA MEMBUAT STOPWATCH DI VISUAL STUDIO
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;
using System.Diagnostics;
namespace stopwatch
{
public partial class Form1 : Form
{
private Stopwatch stopw = null;
public Form1()
{
InitializeComponent();
}
private void button2_Click(object sender, EventArgs e)
{
stopw = new Stopwatch();
stopw.Start();
button1.Enabled = false;
}
private void timer1_Tick(object sender, EventArgs e)
{
if (stopw != null)
{
label1.Text = stopw.Elapsed.ToString(@"hh\:mm\:ss");
}
}
private void button1_Click(object sender, EventArgs e)
{
stopw.Stop();
button1.Enabled = true;
}
private void button3_Click(object sender, EventArgs e)
{
stopw.Restart();
button1.Enabled = true;
}
}
}
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;
using System.Diagnostics;
namespace stopwatch
{
public partial class Form1 : Form
{
private Stopwatch stopw = null;
public Form1()
{
InitializeComponent();
}
private void button2_Click(object sender, EventArgs e)
{
stopw = new Stopwatch();
stopw.Start();
button1.Enabled = false;
}
private void timer1_Tick(object sender, EventArgs e)
{
if (stopw != null)
{
label1.Text = stopw.Elapsed.ToString(@"hh\:mm\:ss");
}
}
private void button1_Click(object sender, EventArgs e)
{
stopw.Stop();
button1.Enabled = true;
}
private void button3_Click(object sender, EventArgs e)
{
stopw.Restart();
button1.Enabled = true;
}
}
}

Komentar
Posting Komentar