Jump to content

clock count down timer

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
13 replies to this topic

#1
Siten0308

Siten0308

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 302 posts
Hello,

just wondering, is there a way i can make a clock where it will conitnue to display the time up-to-date, meaning you will see the time and it will keep continuing to keep track of time progressivly so you can see it live? is that possible, i want to do something fun like you see the clock on the program, and if no mousemove, then after 10 seconds of clocktime passes without mousemove, close program, almost like those annoying websites when the session has timed out :) let me know if that is possible, i am sure but is it datetime class or what?

Thanks

#2
mr_skyflakes21

mr_skyflakes21

    Learning Programmer

  • Members
  • PipPipPip
  • 54 posts
Absolutely there is a way.

#3
Vswe

Vswe

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 9,552 posts
You can add a timer with the interval 1000 and in its tickhandle you can add something like this:

 
label.Text = Now;


#4
Siten0308

Siten0308

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 302 posts
umm... i hate to burst that idea but the label1.Text = Now; does not work, sure thats not going to work, i mean the now is not going to work, i tried it and still does not work, you probably mean datetime.now, which does work i know that already, but how can i continue to keep counting or keep current time (continue seeing it keep live time) if that makes any sense, i will take a look at the interval 1000 thing.

If someone can help to solve the question thanks

#5
Vswe

Vswe

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 9,552 posts
I'm on vaccation now so I can't test anything, but to make it update you make so the text will change to the current time each time the timer ticks. Didn't that work?

#6
Siten0308

Siten0308

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 302 posts
how do you do that "change the text so it changes with the datetime.now"? is it a property or something?

#7
Vswe

Vswe

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 9,552 posts
Didn't you said it worked?

#8
Siten0308

Siten0308

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 302 posts
ok i think we are both getting confused here, let me explain, label1.Text = datetime.now is YES showing date and time correct, however, you dont see it update itself live, meaning you see the seconds counting etc. which is what i want, then i can therefore use interval to say after 1000 (miliseconds) shutdown program, later on i am going to use mouse event mousemove to if user does not do mouse move on form1 then interval 1000 miliseconds then close out program completely... cool huh but i would like to show the time though live and counting, its not working, the only thing is the program starts, you see the date and time however the time stays of where it first launched the program thats it. i hope this explains everything.

Thank you

#9
ArekBulski

ArekBulski

    Speaks fluent binary

  • Members
  • PipPipPipPipPipPipPipPip
  • 1,376 posts
So you add a Timer that has some code like this. Then what?
label1.Text = DateTime.Now.ToString();


#10
Vswe

Vswe

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 9,552 posts
that's since you only use label1.Text = datetime.now when the program starts, you need the program to use label1.Text = datetime.now once a second and that's what you have the timer for.

#11
Siten0308

Siten0308

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 302 posts
Hello and thank you Arek,

Yup that worked, but the difference is with Arek's he used the Timer class and then it named it automatically to timer when when you drop it on the form, you then just assign the timer to label1. BUT MAKE SURE YOU ENABLE IT!!! lol by default it does not get enabled so therefore it keeps you scratching your head wondering why its still not working, other than that, after dropping the timer, double clicking on timer1, putting the code that Arek said, AND ENABLING IT in the properties box, it now works, you see the time live. awesome thanks Arek.

#12
Vswe

Vswe

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 9,552 posts
Just what I tried to tell you. Glad It worked for you. :D