Check Time

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am a starter of Vb .net
I want to write a application to check the time and do corresponding action
For exampl
I set 10:30 to do a action : display "hello world" Messag

So I Start up the program and it will run,
It will get current time and compare with 10:30, if they are equal, then display " hello world

But How to make a program check the time continously.......

Thank You X 1000000000000
 
You could try:

1) Create a new windows forms project
2) Drop a timer on the form
3) Enable the timer and set its Inteval to 60000 (one minute)
4) In the "Tick" event of the timer (double click on the timer in the form
designer), add the following code:

-----------------------
If Date.Now.TimeOfDay.CompareTo(New TimeSpan(10, 30, 0)) >= 0 Then

' Stop the timer
Timer1.Enabled = False

' Show the message
MessageBox.Show("Hello World!")

End If
 
What you can do alternatively is, check the time when the program starts and
get the difference between the intended alarm time and the current time, set
a new timer with interval equal to this difference and in the tick, show
your message. Lets say your program starts at 9:30, so set a counter to tick
after one hour and use the tick handler to show your message.

I am not sure whether its the cleanest way to achieve it but it should
work!!

--Saurabh
 
* "=?Utf-8?B?RmF0Ym95Q2FudGVlbg==?= said:
I am a starter of Vb .net,
I want to write a application to check the time and do corresponding action.
For example
I set 10:30 to do a action : display "hello world" Message

So I Start up the program and it will run,
It will get current time and compare with 10:30, if they are equal, then display " hello world "

But How to make a program check the time continously........

Have a look at the toolbox: You will find a component called Timer
there ('System.Windows.Forms.Timer'). Place it on the form and set its
'Interval' and 'Enabled' properties, add code for comparing the date to
its 'Tick' event handler.
 
Back
Top