473,383 Members | 1,877 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

Get time event at a specific time

Hi!

Is it possible to get a time event at a specific time, for instance
eight a'clock? My program is running in the background and is
minimized to the tray bar.

If not, is there a smooth way to accomplish this in a different way?

Best regards,
Andreas Lundgren
Jul 17 '05 #1
10 24436

"Andreas" <d9****@efd.lth.se> wrote in message
news:f7**************************@posting.google.c om...
Hi!

Is it possible to get a time event at a specific time, for instance
eight a'clock? My program is running in the background and is
minimized to the tray bar.

If not, is there a smooth way to accomplish this in a different way?

Best regards,
Andreas Lundgren


Just put a timer control on the form and set it to fire every second.

Somewhere in the code you set your target:

Dim Target As Date
Target = "10/4/2003 8:00 PM"

And in the timer code you check for this target:

Private Sub Timer1_Timer()
If Now => Target Then
' fire the event that you need to happen at the target time
End If
End Sub
Jul 17 '05 #2
On Fri, 03 Oct 2003 08:57:08 GMT, "Raoul Watson"
<Wa*****@IntelligenCIA.com> wrote:

"Andreas" <d9****@efd.lth.se> wrote in message
news:f7**************************@posting.google. com...
Hi!

Is it possible to get a time event at a specific time, for instance
eight a'clock? My program is running in the background and is
minimized to the tray bar.

If not, is there a smooth way to accomplish this in a different way?

Best regards,
Andreas Lundgren
Just put a timer control on the form and set it to fire every second.

Somewhere in the code you set your target:

Dim Target As Date
Target = "10/4/2003 8:00 PM"

Hmm, that could have rather different results in the UK to the same
code in the USA

Personally I would use DateSerial() and TimeSerial() to avoid such
ambiguity
And in the timer code you check for this target:

Private Sub Timer1_Timer()
If Now => Target Then
' fire the event that you need to happen at the target time
End If
End Sub


Jul 17 '05 #3
Probably the simplest way is to set a timer event (interval=1000) that
checks the value of Time$

' Timer object: Name="tmrTimeTrap" Interval=1000
'
Private Sub tmrTimeTrap_Timer()
If (Time$="08:00" or Time$="20:00") Then
Print "Do this thing at 8 o'clock"
End If
End Sub
Is it possible to get a time event at a specific time, for instance
eight a'clock? My program is running in the background and is
minimized to the tray bar.

Jul 17 '05 #4
"J French" <er*****@nowhere.com> wrote in message
news:3f**************@news.btclick.com...
On Fri, 03 Oct 2003 08:57:08 GMT, "Raoul Watson"
<Wa*****@IntelligenCIA.com> wrote:

"Andreas" <d9****@efd.lth.se> wrote in message
news:f7**************************@posting.google. com...
Hi!

Is it possible to get a time event at a specific time, for instance
eight a'clock? My program is running in the background and is
minimized to the tray bar.

If not, is there a smooth way to accomplish this in a different way?

Best regards,
Andreas Lundgren


Just put a timer control on the form and set it to fire every second.

Somewhere in the code you set your target:

Dim Target As Date
Target = "10/4/2003 8:00 PM"

Hmm, that could have rather different results in the UK to the same
code in the USA

Personally I would use DateSerial() and TimeSerial() to avoid such
ambiguity

And in the timer code you check for this target:

Private Sub Timer1_Timer()
If Now => Target Then
' fire the event that you need to happen at the target time
End If
End Sub


You're absolutely right.
I was merely saying you set a target to give a quick example of the timer
code which is what the poster was looking for.
Jul 17 '05 #5
On Fri, 03 Oct 2003 23:45:45 GMT, "Raoul Watson"
<Wa*****@IntelligenCIA.com> wrote:

<snip>

You're absolutely right.
I was merely saying you set a target to give a quick example of the timer
code which is what the poster was looking for.


Sorry, I get nervous of Dates

- the 'real' answer - compare with a target is exactly how I would do
it
Jul 17 '05 #6
Another possibility is to set the timer interval to the difference between
8:00 and "now". In VB.NET, you could implement a function like this:

Private Function IntervalTill(ByVal d As DateTime) As Integer

Dim TodayTickTime As DateTime = Today.Add(d.Subtract(#12:00:00 AM#))
Dim TomorrowTickTime As DateTime = TodayTickTime.AddHours(24)
Dim Difference As TimeSpan

If DateTime.op_LessThan(Now, TodayTickTime) Then
Difference = TodayTickTime.Subtract(Now)
Else
Difference = TomorrowTickTime.Subtract(Now)
End If

Return Difference.TotalMilliseconds

End Function

Then you could set your timer interval like this:

Timer1.Interval = IntervalTill(#8:00:00 PM#)

This will avoid the overhead of timer code executing once a second (and
potentially 86,399 times without doing anything). Also, if the event needs
to happen every day at the same time, the code in the timer's Tick event
could do its thing and then reset its own interval as above.

Hope this helps. =c)
CajunCoiler wrote:

Probably the simplest way is to set a timer event (interval=1000) that
checks the value of Time$

' Timer object: Name="tmrTimeTrap" Interval=1000
'
Private Sub tmrTimeTrap_Timer()
If (Time$="08:00" or Time$="20:00") Then
Print "Do this thing at 8 o'clock"
End If
End Sub
Is it possible to get a time event at a specific time, for instance
eight a'clock? My program is running in the background and is
minimized to the tray bar.

Jul 17 '05 #7
Problem in VB6 (no idea about .NET) is that the Interval is a 16 byte
value with a mamimum value of 65535 ms, about one minute...

I was thinking and hoping that there might be an API call or upgraded
timer that could give me an event after a longer time, and by that,
let me use a function like the one that Coiler described below.

"1 to 65,535 Sets an interval (in milliseconds) that takes effect
when a Timer control's Enabled property is set to True. For example, a
value of 10,000 milliseconds equals 10 seconds. The maximum, 65,535
milliseconds, is equivalent to just over 1 minute."

"Tony Vitonis" <no***@nowhere.com> wrote in message news:<Mv********************@comcast.com>...
Another possibility is to set the timer interval to the difference between
8:00 and "now". In VB.NET, you could implement a function like this:

Private Function IntervalTill(ByVal d As DateTime) As Integer

Dim TodayTickTime As DateTime = Today.Add(d.Subtract(#12:00:00 AM#))
Dim TomorrowTickTime As DateTime = TodayTickTime.AddHours(24)
Dim Difference As TimeSpan

If DateTime.op_LessThan(Now, TodayTickTime) Then
Difference = TodayTickTime.Subtract(Now)
Else
Difference = TomorrowTickTime.Subtract(Now)
End If

Return Difference.TotalMilliseconds

End Function

Then you could set your timer interval like this:

Timer1.Interval = IntervalTill(#8:00:00 PM#)

This will avoid the overhead of timer code executing once a second (and
potentially 86,399 times without doing anything). Also, if the event needs
to happen every day at the same time, the code in the timer's Tick event
could do its thing and then reset its own interval as above.

Hope this helps. =c)
CajunCoiler wrote:

Probably the simplest way is to set a timer event (interval=1000) that
checks the value of Time$

' Timer object: Name="tmrTimeTrap" Interval=1000
'
Private Sub tmrTimeTrap_Timer()
If (Time$="08:00" or Time$="20:00") Then
Print "Do this thing at 8 o'clock"
End If
End Sub
Is it possible to get a time event at a specific time, for instance
eight a'clock? My program is running in the background and is
minimized to the tray bar.

Jul 17 '05 #8
On 14 Oct 2003 02:32:09 -0700, d9****@efd.lth.se (Andreas) wrote:
Problem in VB6 (no idea about .NET) is that the Interval is a 16 byte
value with a mamimum value of 65535 ms, about one minute...

I was thinking and hoping that there might be an API call or upgraded
timer that could give me an event after a longer time, and by that,
let me use a function like the one that Coiler described below.


I think you misunderstand what he was saying

As everyone suggested, set up a Timer that fires every second, and
checks whether the system time has reached a specified forward date.
Jul 17 '05 #9
This link is to an MSDN library article on using timers through the API. You can
set a timer up to 4 billion milliseconds ahead, which is about 49.7 days. Not
suprisingly, I haven't tested one set that long.

http://support.microsoft.com/default...b;en-us;180736

"Andreas" <d9****@efd.lth.se> wrote in message
news:f7**************************@posting.google.c om...
Problem in VB6 (no idea about .NET) is that the Interval is a 16 byte
value with a mamimum value of 65535 ms, about one minute...

I was thinking and hoping that there might be an API call or upgraded
timer that could give me an event after a longer time, and by that,
let me use a function like the one that Coiler described below.

"1 to 65,535 Sets an interval (in milliseconds) that takes effect
when a Timer control's Enabled property is set to True. For example, a
value of 10,000 milliseconds equals 10 seconds. The maximum, 65,535
milliseconds, is equivalent to just over 1 minute."

"Tony Vitonis" <no***@nowhere.com> wrote in message

news:<Mv********************@comcast.com>...
Another possibility is to set the timer interval to the difference between
8:00 and "now". In VB.NET, you could implement a function like this:

Private Function IntervalTill(ByVal d As DateTime) As Integer

Dim TodayTickTime As DateTime = Today.Add(d.Subtract(#12:00:00 AM#))
Dim TomorrowTickTime As DateTime = TodayTickTime.AddHours(24)
Dim Difference As TimeSpan

If DateTime.op_LessThan(Now, TodayTickTime) Then
Difference = TodayTickTime.Subtract(Now)
Else
Difference = TomorrowTickTime.Subtract(Now)
End If

Return Difference.TotalMilliseconds

End Function

Then you could set your timer interval like this:

Timer1.Interval = IntervalTill(#8:00:00 PM#)

This will avoid the overhead of timer code executing once a second (and
potentially 86,399 times without doing anything). Also, if the event needs
to happen every day at the same time, the code in the timer's Tick event
could do its thing and then reset its own interval as above.

Hope this helps. =c)
CajunCoiler wrote:

Probably the simplest way is to set a timer event (interval=1000) that
checks the value of Time$

' Timer object: Name="tmrTimeTrap" Interval=1000
'
Private Sub tmrTimeTrap_Timer()
If (Time$="08:00" or Time$="20:00") Then
Print "Do this thing at 8 o'clock"
End If
End Sub

> Is it possible to get a time event at a specific time, for instance
> eight a'clock? My program is running in the background and is
> minimized to the tray bar.

Jul 17 '05 #10
Thanks!

This was what I wanted! As you can see, I'm don't like to following
standard MS coding standard, "Make the timer go of every second, and
if the computer gets slower, why not upgrade to a faster processor?".

"Steve Gerrard" <no*************@comcast.net> wrote in message news:<nY********************@comcast.com>...
This link is to an MSDN library article on using timers through the API. You can
set a timer up to 4 billion milliseconds ahead, which is about 49.7 days. Not
suprisingly, I haven't tested one set that long.

http://support.microsoft.com/default...b;en-us;180736

"Andreas" <d9****@efd.lth.se> wrote in message
news:f7**************************@posting.google.c om...
Problem in VB6 (no idea about .NET) is that the Interval is a 16 byte
value with a mamimum value of 65535 ms, about one minute...

I was thinking and hoping that there might be an API call or upgraded
timer that could give me an event after a longer time, and by that,
let me use a function like the one that Coiler described below.

"1 to 65,535 Sets an interval (in milliseconds) that takes effect
when a Timer control's Enabled property is set to True. For example, a
value of 10,000 milliseconds equals 10 seconds. The maximum, 65,535
milliseconds, is equivalent to just over 1 minute."

Jul 17 '05 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: dhourd | last post by:
I'm performing a conversion of code from C to C# and I want to perform a callback to a function where the callback is performed at a certain time, like 2 March 2004 at 1:35pm. I realise there...
1
by: agro_r | last post by:
I use this code in my program: while(form.Created) { form.CheckTime(); Application.DoEvents(); }
9
by: Andreas Lundgren | last post by:
Hi! Is it possible to get a time event at a specific time, for instance eight a'clock? My program is running in the background and is minimized to the tray bar. If not, is there a smooth way...
3
by: Just Me | last post by:
If I move the mouse cursor over a control and stop moving I get a MouseHover event. If I then move the cursor while staying within the control and then stop moving I do not get another...
1
by: Niron kag | last post by:
Hello! I want to run a specific program every day or month - in specific time automatically. Can you tell me please what is the best way to do it? Thank U!
3
by: hygeena | last post by:
Hi, I m working with access.we hav a table history stores the employee IN/OUT time details...The IN/OUT time details s stored in the same field as event time....I want to get the...
1
by: Daz | last post by:
Hello everyone. I'm making a JavaScript clock which works in real time, and supports every time zone. I am struggling to find a way to see when the clocks are set back or forwards in a specific...
2
by: bharathreddy | last post by:
This is insight I would like to share how to restrict application from doing some tasks on specific time in specific timezone. Like if we want to restrict our application to work only from...
1
by: rosae619 | last post by:
Hi all, Here I want to execute batch files for certain time located in a folder. I want to execute in such fashion: 1) First batch (it executes for certain time, get terminated)
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.