How to Create Stop Watch using C# .NET

I have been create a simple software Stop Watch but unbelievable for me.

below link of Stop Watch Software

Click Here for Download Stop Watch

If you want to create this software so follow below step:

Open visual studio.
See the form:

 










Collect from toolbar label and command button.


 Copy below code.
..........................................................................................
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 WinStopWatch
{
    public partial class Form2 : Form
    {
        public Form2()
        {
            InitializeComponent();
        }
// Varialble
        int ms, s, m, h;

// Timer code
        private void timer1_Tick(object sender, EventArgs e)
        {  
            ms=ms+1;
            if(ms==9)
             {
                ms=0;                   
                s=s+1;
                lblS.Text = s.ToString();
                if(s==59)
                {
                s=0;
                m=m+1;

                lblM.Text = m.ToString();
                if(m==59)
                {
                m=0;
                h=h+1;
                lblH.Text = h.ToString();
                }
             }
           }
            lblMS.Text = ms.ToString();
        }
//Commad button Start double click paste below code:
        private void btnStart_Click(object sender, EventArgs e)
        {
            timer1.Enabled = true;
            //lblMS.Text = "0";
            lblS.Text = "0";
            lblM.Text = "0";
            lblH.Text = "0";
        }
//Commad button Stop double click paste below code:
        private void bntStop_Click(object sender, EventArgs e)
        {
            timer1.Enabled = false;
        }
//Commad button Reset double click paste below code:
        private void btnReset_Click(object sender, EventArgs e)
        {
            ms = 0;
            s = 0;
            m = 0;
            h = 0;
            timer1.Enabled = false;
            lblMS.Text = "0";
            lblS.Text = "0";
            lblM.Text = "0";
            lblH.Text = "0";

        }
    }
}

No comments: