Solved

Timer

Posted on 2000-04-19
13
149 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
NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

 

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 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 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

770 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