Minggu, 22 April 2018

CARA MEMBUAT STOPWATCH DENGAN VISUAL STUDIO 2010

Stopwatch 

  

Program Stopwatch 


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;

// script tambahan
using System.Diagnostics;

namespace Stopwatch5
{
    public partial class Form1 : Form
    {
        //tambahan script
        private Stopwatch stopw = null;
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            stopw = new Stopwatch();
            stopw.Start();
            button1.Enabled = false;
        }

        private void button2_Click(object sender, EventArgs e)
        {
            stopw.Stop();
            button1.Enabled=true;
        }

        private void label1_Click(object sender, EventArgs e)
        {

        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            if (stopw != null)
            {
                label1.Text = stopw.Elapsed.ToString(@"hh\:mm\:ss");
            }
        }

        private void button3_Click(object sender, EventArgs e)
        {
            stopw.Reset();
            button3.Enabled=true;
       
        }

        private void button4_Click(object sender, EventArgs e)
        {
            stopw.Start();
            button4.Enabled = true;
        }
    }
}


Tidak ada komentar:

Posting Komentar