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
Solved

Timer

Posted on 2000-04-19
13
151 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
Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

 

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

856 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