Membuat Stopwatch with Visual Basic :)




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 label1_Click(object sender, EventArgs e)
        {

        }

        private void button1_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 button2_Click(object sender, EventArgs e)
        {
            stopw.Stop();
            button1.Enabled = true;
        }
    }
}

Komentar