Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Scheduler Program in VB 5.0 or VC 5.0

Status
Not open for further replies.

4prakash

Programmer
Sep 26, 2002
3
US
Hi,

Have anyone worked toward creating a Scheduler Program in VB 5.0 or VC 5.0? I have requirement as follows:
The Scheduler updates a text file every Saturday (at 9.00 AM EST). The data is read from a MS Access db Table and updated into the Text File. It also deletes the old files.

Any similar code snippet or help / approach appreciated!

Regards,
Prakash.
 
You need a couple things to do this.

One, you need save when the last update occurred. This would preferrably be in the text file since that's what's getting updated.

Two, you need a timer (something that will trigger automatically "interval of your choice").

When the timer gets triggered you compare the current date with the last updated time. If there's a Saturday 9am EST between the two, you update the file and reset your last updated time. That way, if they turn off the app for a while, next time it gets turned on (turn off Friday night and back on Sunday morning) it'll know that it needs to update the file and will do so.

One way to check to see if you went past Saturday 9am would be to take the current date/time and find the prior Saturday 9am. If it's Wednesday (you can use weekday() go get day of week) and subtract 4 days to get saturday and append a hard coded 9am, using something like:

Dim dLastSat As Date
Dim dToday As Date
Dim dNum As Integer

dToday = Now
If Weekday(dToday) < 7 Then
dNum = -(7 - (7 - Weekday(dToday)))
Else
dNum = 0
End If
dLastSat = CDate(DateValue(DateAdd(&quot;d&quot;, -4, Now)) & &quot; 09:00:00&quot;)

From here you just see if the last update is < dLastSat, if it is, then you went past a Saturday 9am.
 
Minor typo.. (forgot to copy last line before repasting back in....

Last line should have been:

dLastSat = CDate(DateValue(DateAdd(&quot;d&quot;, dNum, dToday)) & &quot; 09:00:00&quot;)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top