Solved

Timer

Posted on 2000-04-19
13
147 Views
Last Modified: 2010-05-02
Hi programmers
I need to write a sub routine that will check the time and date and fire on a specified time and date.  This needs to run continually.  any ideas?
0
Comment
Question by:BBrian
  • 2
  • 2
  • 2
  • +5
13 Comments
 
LVL 28

Accepted Solution

by:
AzraSound earned 100 total points
ID: 2731636
looks like you have the right idea...using a timer to continuously check the value of the time and date and when it finds a match, fire away

be sure to use pound signs when performing your check, for example:

If Now = #4/19/2000 1:20pm# Then
0
 

Expert Comment

by:gmatthew
ID: 2731674
All you need to do is enable the timer and set the interval property.  The smaller the interval, the better the accuracy of the event.  At that point, the timer will run the code that resides within the Timer11_Timer event at every specified interval. You can put something like the following in that event:

If datetime.now = TRIGGERDATETIME Then
     YOUR CODE HERE
End If

TRIGGERDATETIME is a constant that contains the Day and Time on which you wish to run your code.

When the desired date and time is reached the code will be run.

0
 
LVL 28

Expert Comment

by:AzraSound
ID: 2731689
gmatthew..welcome to EE...it is customary here to just post comments.  The person asking the question can accept a comment at anytime as an answer.
0
 

Expert Comment

by:gmatthew
ID: 2731700
gmatthew changed the proposed answer to a comment
0
 

Expert Comment

by:BPR
ID: 2731833
Hi Brian
What is your work environment.If NT there is a scheduling tool called winat which can do this job of starting the program application at specified time & date.
So you need not have your program waiting for the vent to happen.
0
 
LVL 69

Expert Comment

by:Éric Moreau
ID: 2731851
I would go for WinAT too!
0
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
LVL 14

Expert Comment

by:wsh2
ID: 2732175
WINAT.. For Windows 98.. it is called Task Scheduler.. For Windows 95 with MS/Plus! it is called System Agent.
0
 
LVL 27

Expert Comment

by:Ark
ID: 2732617
Hi
> Sub routine ....to run continually
???  You mean application?
If so, add a string entry in HKLM\Software\Microsoft\Windows\CurrentVersion\Run.  The entry's name should be the name of your application (ex: MyApp).  Its value must be the short path to your application (ex. C:\Windows\MyApp.exe). And your app will start every time when window boot. Also, you need some settings for your aplication - TimerInterval, DateTimeToFire and AppName. You can store these values at registry too. As for checking code, you already received it at previous comments.
BTW, I hope that your date won't be 26th of April <smile>
Cheers
0
 

Author Comment

by:BBrian
ID: 2733484
BPR
I have NT.  How do I use WinaT?
I have the program working using the timer.  This is suppose to sit on the machine all the time and fire a program once a week on a specified day and time.
The timer fires once a minute.  I wonder if this is the most efficient way to do it.  If the program fires once a week.  It seems waistful to check every minute.
0
 
LVL 14

Expert Comment

by:wsh2
ID: 2733515
The maximum interval a timer can be set to is just over 1 minute (65,535 Milliseconds), so in that you have no choice. As far as dragging the machine down, I doubt that very much. The Date/Time you are comparing is already loaded into the operating system. Since all you are doing is comparing one memory location to another, this is hardly a load on the processor. If you will recall, processor speeds are measured in nanoseconds (billionths of a second); as your very simple application is only firing once a minute.. there really is no comparison.
0
 
LVL 69

Expert Comment

by:Éric Moreau
ID: 2734333
Launch WinAT.

You have a GUI in which you add the path to your application ans also set time interval!
0
 

Expert Comment

by:c_sh
ID: 2743209
BBrian :
   Insted of checking time on every minute why don't you just check the date or day  only once ie. when the system boots up.

If the day/date matches with yours, then you can launch your application.
0
 

Author Comment

by:BBrian
ID: 2777243
Thanks
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now