Solved

Timer

Posted on 2000-04-19
13
153 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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 70

Expert Comment

by:Éric Moreau
ID: 2731851
I would go for WinAT too!
0
 
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 28

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 70

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

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…

751 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