date and timer on a form

  • Thread starter Thread starter aelhhattabi
  • Start date Start date
A

aelhhattabi

hi,

I'm new to vb.net . I have a problem waking up early. I usually miss my
morning classes. I downloaded some alarm clocks of the internet but most of
them are huge and have extra functionalities. so I decided to make my own
alarm clock. i created my project and made the form. I could display the
time on a textfield but I dont know how to make it increment like a clock
does. would anyone plz start me on the right track ?

thanks
 
Hi,

Add a timer to your form. In the tick event update the textbox
text. Set the timers interval to 1000 and enabled to true.

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Timer1.Tick

TextBox1.Text = Now.ToShortTimeString

End Sub



Ken
 
* "aelhhattabi said:
I'm new to vb.net . I have a problem waking up early. I usually miss my
morning classes. I downloaded some alarm clocks of the internet but most of
them are huge and have extra functionalities. so I decided to make my own
alarm clock. i created my project and made the form. I could display the
time on a textfield but I dont know how to make it increment like a clock
does. would anyone plz start me on the right track ?

Add a timer ('System.Windows.Forms.Timer') to your form, set its
'Interval' property to '500' (milliseconds), then doubleclick it to
create a handler for its 'Tick' event. There you can calculate the
difference between a starting date (for example, stored in a private
variable) with the current date/time ('DateTime.Now') and display it by
calling the resulting 'TimeSpan''s 'ToString' method.
 
Back
Top