Dkid Posted April 27, 2008 at 01:52 PM Report Share #181655 Posted April 27, 2008 at 01:52 PM Boas pessoal, estou com um problema a trabalhar com o timer... O que pretendo é que haja um tempo especifico (240 segundos) e que esses 240 segundos sejam vistos a decrescer numa label, até zero Mas estou com problemas a faze-lo alguem me pode ajudar ? Obrigado I promise that I will not change the PATH variable again other than:PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games Link to comment Share on other sites More sharing options...
Betovsky Posted April 28, 2008 at 01:26 PM Report Share #181891 Posted April 28, 2008 at 01:26 PM Tens várias formas de fazer isso. Se queres usar um timer, então aconselhava-te a teres um período pequeno, tipo 1 segundo. Em cada tick então decrescerias o valor na label. Quando chegasse a zero, fazias stop ao timer. "Give a man a fish and he will eat for a day; Teach a man to fish and he will eat for a lifetime. The moral? READ THE MANUAL !" Sign on a computer system consultant's desk Link to comment Share on other sites More sharing options...
killercode Posted April 28, 2008 at 01:29 PM Report Share #181893 Posted April 28, 2008 at 01:29 PM Aqui vai o codigo 🙂 using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; namespace Count_Down { public partial class Form1 : Form { private Int32 iCountDown = 240; public Form1() { InitializeComponent(); label1.Text = iCountDown.ToString(); } private void timer1_Tick(object sender, EventArgs e) { iCountDown -= 1; label1.Text = iCountDown.ToString(); if (iCountDown == 0) { timer1.Stop(); } } private void button1_Click(object sender, EventArgs e) { timer1.Interval = 1000; iCountDown = 240; timer1.Start(); } } } Geek PressWeboeste.Com Link to comment Share on other sites More sharing options...
Dkid Posted April 28, 2008 at 07:59 PM Author Report Share #182083 Posted April 28, 2008 at 07:59 PM Boas, obrigado pelas respostas O que pretendia era tao simples que se tivesse olhado melhor, mesmo sem nunca ter usado o Timer tinha realizado... int tempo = 10; private void timer1_Tick(object sender, EventArgs e) { tempo--; label1.Text = tempo.ToString(); } I promise that I will not change the PATH variable again other than:PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now