Soneka Posted November 26, 2007 at 08:01 PM Report Share #150501 Posted November 26, 2007 at 08:01 PM Boas, qual é a linha de código para meter um simples relógio com as horas reais numa windows form application? Aguardo pela resposta. 😛 Link to comment Share on other sites More sharing options...
zeroonnet Posted November 26, 2007 at 08:05 PM Report Share #150502 Posted November 26, 2007 at 08:05 PM metes um timer a actualizar de 10000 Milissegundos em 10000 Milissegundos e a mudar a textbox ou la o que for para textBox1.Text = DateTime.Now.Hour.ToString() + ":" + DateTime.Now.Minute.ToString(); Link to comment Share on other sites More sharing options...
Soneka Posted November 26, 2007 at 08:24 PM Author Report Share #150507 Posted November 26, 2007 at 08:24 PM Obrigado 😛 Link to comment Share on other sites More sharing options...
Betovsky Posted November 26, 2007 at 08:26 PM Report Share #150508 Posted November 26, 2007 at 08:26 PM Ou então apenas textBox1.Text = DateTime.Now.ToString("t"); "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...
zeroonnet Posted November 26, 2007 at 08:37 PM Report Share #150510 Posted November 26, 2007 at 08:37 PM ou entao DateTime.Now.ToString("HH:mm"); Link to comment Share on other sites More sharing options...
Soneka Posted November 26, 2007 at 08:49 PM Author Report Share #150517 Posted November 26, 2007 at 08:49 PM bah... mas eu quero k o tempo esteja sempre a "passar", a "andar" nao k tenha k clickar ou escrever algo para saber as horas. Link to comment Share on other sites More sharing options...
zeroonnet Posted November 26, 2007 at 08:54 PM Report Share #150518 Posted November 26, 2007 at 08:54 PM lol faz assim: crias um timer com a Toolbox e nas propriedades metes no Interval: 10000 depois clicas no simbolo que parece um torvao nas propriedades e fazes duplo click onde diz: Tick aquilo vai-te levar ao code e metes lá: textBox1.Text = DateTime.Now.Hour.ToString() + ":" + DateTime.Now.Minute.ToString(); Link to comment Share on other sites More sharing options...
Soneka Posted November 26, 2007 at 08:55 PM Author Report Share #150519 Posted November 26, 2007 at 08:55 PM espero k dê.. vou testar lol. Link to comment Share on other sites More sharing options...
Soneka Posted November 26, 2007 at 09:11 PM Author Report Share #150521 Posted November 26, 2007 at 09:11 PM ainda nao é bem aquilo k tava à espera k fosse.. mas serve 😛 Link to comment Share on other sites More sharing options...
zeroonnet Posted November 26, 2007 at 09:15 PM Report Share #150526 Posted November 26, 2007 at 09:15 PM tao queres o que? :S msotra as horas que pelo que me pareceu foi isso que pediste.... P.S. Muda-me esses "k" para que... Link to comment Share on other sites More sharing options...
Soneka Posted November 26, 2007 at 09:23 PM Author Report Share #150529 Posted November 26, 2007 at 09:23 PM Epa afinal ta bom, obrigado. Só queria saber se dá para meter segundos? 😛 Link to comment Share on other sites More sharing options...
mobes Posted November 27, 2007 at 12:00 AM Report Share #150565 Posted November 27, 2007 at 12:00 AM Se te disseram que para as horas era DateTime.Now.Hour.ToString() e para os minutos era DateTime.Now.Minute.ToString() para os segundos será.. vá.. DateTime.Now.Second.ToString(). 😛 textBox1.Text = DateTime.Now.Hour.ToString() + ":" + DateTime.Now.Minute.ToString() + ":" + DateTime.Now.Second.ToString(); E o Interval no Tick deve estar para 1000 e não para 10000... Link to comment Share on other sites More sharing options...
Betovsky Posted November 27, 2007 at 12:04 AM Report Share #150566 Posted November 27, 2007 at 12:04 AM Epá, não façam concatenação de Strings que isso é horrível, para além de ser terrivelmente ineficiente. Neste caso usem DateTime.Now.ToLongTimeString(); ou DateTime.Now.ToString("T"); ou DateTime.Now.ToString("HH:mm:ss"); "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...
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