Solved

Timer

Posted on 2000-04-19
13
148 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Write data from SQL to CSV file - position 1 53
vb6 connector to SQL Server 2 34
MS Date Picker 64 bit 32 bit issue 12 49
Hide vba in gp 7 83
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
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…

895 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

14 Experts available now in Live!

Get 1:1 Help Now