Timer in c#.net
Code
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace StopWatch
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
timer1.Enabled = true;
}
private void timer1_Tick(object sender, EventArgs e)
{
int i = int.Parse(label6.Text);
i++;
if (i < 10)
label6.Text = (i).ToString();
else
{
label6.Text = "0";
int j = int.Parse(label5.Text);
j++;
if (j < 6)
{
label5.Text = (j).ToString();
}
else
{
label5.Text="0";
int k=int.Parse(label4.Text);
k++;
if(k<10)
{
label4.Text=(k).ToString();
}
else
{
label4.Text="0";
int l=int.Parse(label3.Text);
l++;
if (l < 6)
{
label3.Text = (l).ToString();
}
else
{
label3.Text = "0";
int m = int.Parse(label2.Text);
m++;
if (m < 10)
{
label2.Text = (m).ToString();
}
else
{
label2.Text = "0";
int n = int.Parse(label1.Text);
n++;
if (n < 7)
{
label1.Text = (n).ToString();
}
}
}
}
}
}
}
private void button2_Click(object sender, EventArgs e)
{
timer1.Enabled = false;
}
}
}
No comments:
Post a Comment