Hello,
Anyone knows how to trigger an event based on system time ?
For example : I want my program to do something at 01:00 AM each day.
Thanks,
Jukke
Printable View
Hello,
Anyone knows how to trigger an event based on system time ?
For example : I want my program to do something at 01:00 AM each day.
Thanks,
Jukke
What do u mean how to trigger a event.
If you want to call a function, just call a function.
If you want to call a event such as command1_click. Click event of command button. Just call it as command1_click().
Or if you want to Raise a event use RaiseEvent().
Right, I can execute events by calling the sub.
Even without events, how can I make my program detect a specific time e.g. 01:00 AM and do something ?
Have a timer that will fire every 1 second. Interval = 1000
In timer click event check the system date/time. if matches with your value ... do some thing.
I think every 1 sec is a bit excessive ..... maybe every 45 or 60 or even 90 seconds should do....
Why didn' I find this myself.
So easy ...
Thanks techyspecy !
Not possible techngome.Quote:
Originally posted by techgnome
I think every 1 sec is a bit excessive ..... maybe every 45 or 60 or even 90 seconds should do....
Lets say he wants to check for 1:00 AM
with 30 sec. timer lets say last time timer got fired at 12:59:45 sec.
next timer will fire at 1:00:15. and he will miss the 1 o clock time.
Yes but he only misses it by 15 seconds and technically its still 1 am its just not EXACTLY with no seconds difference. And then the timer doesn't poll the system near as much making it more effective.
The trigger doesn't have to be on the second. More or less around the specified time will do the trick.
Thanks guys !
:D
You might wanna put your program in the task bar if its running for a specifyed time...
I can give ya what haz been given to me...
The taskbar code :p... if your want.
Quote:
Originally posted by Jukke
Why didn' I find this myself.
So easy ...
Thanks techyspecy !
90 seconds could skip over 1:00
say, 12:59:50 to 1:01:20
Thats true 90 seconds could skip it, but you can still use 45 or 60 would work. Or 90 if you don't mind the extra 30 seconds.
If its not a matter of seconds then he has lot of options ....
Hey Ruku,
I've been wanting to put something together that combines both the "timer" event (like from the orig. post) combined with the "min. to sys. tray" that you mentioned.
Think I could get the "task bar" code?
Thanks,
ittybitty
BTW: this is a great board, found it not too long ago and have got a lot of useful info.
Thanks people.
I think there is no problem with any size of timestep (30 sec or even 300 sec) if you do not check for the exact time ( = 01:00). Just check for a timeperiod that is from 01:00 to 01:00 + timestep.
Well similar problems are solved as follows...
set a timer...
The timer can only time for about 60,000 ms (1 minute)
set the delay time to one of the following:
- another minute if the time you want is MORE than a minute away...
- the number of seconds left untill that time
This will get you exactly where you want...