473,508 Members | 2,274 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 24445

"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
15245
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
243
by: agro_r | last post by:
I use this code in my program: while(form.Created) { form.CheckTime(); Application.DoEvents(); }
9
2498
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
3019
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
2221
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
1782
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
2257
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
3224
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
3017
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
7129
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7333
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
5057
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4716
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3208
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3194
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1566
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
769
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
428
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.