0% found this document useful (0 votes)
47 views1 page

Timer: Public Partial Class New

This C# code defines a timer that counts down the time remaining until a specified New Year's Eve event date. When the form loads, it displays the event date and current date in labels. The timer then continuously updates the current date label and calculates the remaining time in days, hours, minutes, and seconds until the event, displaying these in other labels.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
47 views1 page

Timer: Public Partial Class New

This C# code defines a timer that counts down the time remaining until a specified New Year's Eve event date. When the form loads, it displays the event date and current date in labels. The timer then continuously updates the current date label and calculates the remaining time in days, hours, minutes, and seconds until the event, displaying these in other labels.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Timer

public partial class Form1 : Form


{
DateTime evento = new DateTime(2019,12,31,23,59,59);
DateTime atual;

public Form1()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)


{
lblFimAno.Text = evento.ToString();
lblDataAtual.Text = DateTime.Now.ToString();
}

private void timer1_Tick(object sender, EventArgs e)


{
atual = DateTime.Now;
lblDataAtual.Text = atual.ToString();

TimeSpan dif = evento.Subtract(atual);


vDia.Text = dif.Days.ToString();
vHora.Text = dif.Hours.ToString();
vMin.Text = dif.Minutes.ToString();
vSeg.Text = dif.Seconds.ToString();
}
}

You might also like