Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Visual Basic > VB 2012 > Visual Basic 2012 General Discussion
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Visual Basic 2012 General Discussion For 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 .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old October 13th, 2014, 11:03 AM
Registered User
Points: 5, Level: 1
Points: 5, Level: 1 Points: 5, Level: 1 Points: 5, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2014
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Program not running during automation

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


blnLine0 = False
If intDay = 1 Or intDay = 2 Or intDay = 3 Or intDay = 4 Then
i = Shell("L:\RoperDP\RoperVBNet\Line1\ModelLine\Line1 .exe NightBuild", vbNormalFocus)
PopulateListView("Line 0 Sequence Program")
ElseIf intDay = 5 Or intDay = 6 Then
PopulateListView("Day " & intDay & " Line 0 Sequence Program SKIPPED")
ElseIf intDay = 7 Then
i = Shell("L:\RoperDP\RoperVBNet\Line1\ModelLine\Line1 .exe NightBuild", vbNormalFocus)
PopulateListView("Day " & intDay & "SUNDAY Line 0 Sequence Program")
End If
End If

It has been changed to this because of the Sunday issue....

If TimeOfDay < #8:00:00 PM# Then
blnLine0 = True
End If
If TimeOfDay > #8:05:00 PM# And blnLine0 Then
Select Case intDay
Case 1
blnLine0 = False
i = Shell("L:\RoperDP\RoperVBNet\Line1\ModelLine\Line1 .exe NightBuild", vbNormalFocus)
PopulateListView("Day " & intDay & " Line 0 Sequence Program BUILD")
Case 2
blnLine0 = False
i = Shell("L:\RoperDP\RoperVBNet\Line1\ModelLine\Line1 .exe NightBuild", vbNormalFocus)
PopulateListView("Day " & intDay & " Line 0 Sequence Program BUILD")
Case 3
blnLine0 = False
i = Shell("L:\RoperDP\RoperVBNet\Line1\ModelLine\Line1 .exe NightBuild", vbNormalFocus)
PopulateListView("Day " & intDay & " Line 0 Sequence Program BUILD")
Case 4
blnLine0 = False
i = Shell("L:\RoperDP\RoperVBNet\Line1\ModelLine\Line1 .exe NightBuild", vbNormalFocus)
PopulateListView("Day " & intDay & " Line 0 Sequence Program BUILD")
Case 5
blnLine0 = False
PopulateListView("Day " & intDay & " Line 0 Sequence Program SKIPPED")
Case 6
blnLine0 = False
PopulateListView("Day " & intDay & " Line 0 Sequence Program SKIPPED")
Case 7
blnLine0 = False
i = Shell("L:\RoperDP\RoperVBNet\Line1\ModelLine\Line1 .exe NightBuild", vbNormalFocus)
PopulateListView("Day " & intDay & "SUNDAY Line 0 Sequence Program")
End Select

End If

Do you have any other suggestions as to why this would occur?

Krissi
Reply With Quote
  #2 (permalink)  
Old October 19th, 2014, 04:06 PM
Registered User
Points: 55, Level: 1
Points: 55, Level: 1 Points: 55, Level: 1 Points: 55, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2014
Location: Colorado
Posts: 9
Thanks: 2
Thanked 2 Times in 2 Posts
Default Re:Program not running during automation

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.

Good luck.
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Running as part of c# program anthonym XSLT 6 December 12th, 2011 07:36 AM
Running a program off the network? myurick Visual Basic 2008 Essentials 4 April 3rd, 2008 02:22 PM
Exception in running a program furqanms Java Basics 2 June 21st, 2006 10:39 PM
running another .exe from my program salhabb C++ Programming 1 January 18th, 2006 05:21 AM



All times are GMT -4. The time now is 03:08 PM.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.