Visual Basic 2012 General DiscussionFor any discussions about Visual Basic 2012topics which aren't related to a specific Wrox book

Welcome to the p2p.wrox.com Forums.

You are currently viewing the Visual Basic 2012 General Discussion section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .

We have a program that is essentially running as a scheduler. Within this program, several others are set to run based on times and dates. I have three programs that are set to run if it is Mon-Thur and Sunday. However, the automation is not running the Sunday request. It works great Mon-Thur. A code was inserted for Fri and Sat to just simply state "SKIPPED" just to verify that this is reading and it is. Several other programs that are ran daily complete without fail. But every Sunday these three programs fail. Currently, they are being manually ran on Monday mornings, and they complete perfectly.

The code was this:

If TimeOfDay < #8:00:00 PM# Then
blnLine0 = True
End If
If TimeOfDay > #8:05:00 PM# And blnLine0 Then

After reviewing your code I have made a few assumptions:
1. Both versions of the code work the same but the first is more compact and probably the better.
2. By comparing both I notice that there is no difference in what is being done in the SELECT version for the Sun-Thur. This makes me wonder if the IF-THEN version should also do the same and that it could/should be written that way.

I assume that you have tried some experimentation to see what's happening as the program is running and here is a list of things I would try:

1. In the IF-THEN version change the first 'if-then' statement to include the 'intDay = 7' condition and remove the last 'elseif' part of the code along with the next three lines of code (including one of the EndIf lines but not both.

2. Depending on how the days of the week are being numbered my experience has shown that Sunday is usually day 0 (zero) and not day seven (7) so change the 'intDay = 7' to read 'intDay = 0' and see if that works.

3. Run the code in a debug environment and place a stop at the beginning of your routine. Check all the variables, especially intDay, and make sure they are what you expected them to be. This could tell you a lot about what needs to be fixed.

4. Check the program that is going to be run, the Shell part and make sure that it will even run on a Sunday. This may require that you actually try to run it, manually, on a Sunday. Translation: the code you posted works perfectly but the app that you Shell to, won't work on Sundays.

5. Lose the SELECT-CASE version as there is no value added using this method and just adds more code that could cause problems.