2
Answers

C# Creating a Timer that at a specific values changes a label

Photo of Jane Abrams

Jane Abrams

12y
2.3k
1
I am new to C#, and I have searched I but didn't find a simple solution to my problem.
I am creating a Windows form application.
After the start button is clicked, it counts every millisecond and when it reaches specific values from an array changes a label.
How can milliseconds be counted?

Answers (2)

1
Photo of Frogleg
NA 7.9k 33k 12y
Here
drag a timer onto form and set interval to 1
 public partial class Form1 : Form
  {
  int milli = 0;
  public Form1()
  {
  InitializeComponent();
  }

  private void button1_Click(object sender, EventArgs e)
  {
  timer1.Start();
  }

  private void timer1_Tick(object sender, EventArgs e)
  {
  milli++;
  label1.Text = milli.ToString();
  }
  }
0
Photo of Jane Abrams
NA 3 2.3k 12y
The result is not in milliseconds