Author Topic: Serios bug in vb6, or is it?  (Read 947 times)

Offline Botsareus

  • Society makes it all backwards - there is a good reason for that
  • Bot God
  • *****
  • Posts: 4483
    • View Profile
    • DJ Paul Kononov
Serios bug in vb6, or is it?
« on: January 31, 2014, 05:59:27 PM »
I can not get the program to exit on "end" statement.
for example:

The following is at the bottom of Public Sub UpdateSim()
Code: [Select]
'R E S T A R T  N E X T
  'Botsareus 1/31/2014 seeding
  If x_restartmode = 1 Then
    If SimOpts.TotRunCycle = 200 Then
        FileCopy MDIForm1.MainDir & "\league\test.txt", NamefileRecursive(MDIForm1.MainDir & "\league\seeded\" & totnvegsDisplayed & ".txt")
        Open App.path & "\restartmode.gset" For Output As #1
         Write #1, x_restartmode
         Write #1, x_filenumber
        Close #1
        x_end = True
        shell App.path & "\Restarter.exe " & App.path & "\" & App.EXEName
        MDIForm1.WindowState = 0
        DoEvents
        MDIForm1.Move 0, 0
    End If
  End If

If I replace the following with "end"

Code: [Select]
        MDIForm1.WindowState = 0
        DoEvents
        MDIForm1.Move 0, 0

The program will not exit no matter what I do.
Any ideas?
« Last Edit: January 31, 2014, 11:49:10 PM by Botsareus »

Offline Botsareus

  • Society makes it all backwards - there is a good reason for that
  • Bot God
  • *****
  • Posts: 4483
    • View Profile
    • DJ Paul Kononov
Re: Serios bugo in vb6
« Reply #1 on: January 31, 2014, 11:48:14 PM »
I was thinking it is because I am calling "shell" right before "end" but maybe it is because the code was nesting from the mdiform startup subroutine.
I am going to try to move the "end" code to the seconds timer tomorrow and see if that fixes it. cross-fingers.
« Last Edit: February 01, 2014, 11:25:55 AM by Botsareus »

Offline Numsgil

  • Administrator
  • Bot God
  • *****
  • Posts: 7713
    • View Profile
Re: Serios bug in vb6, or is it?
« Reply #2 on: February 01, 2014, 11:55:08 AM »
I believe the program will block until the shell command finishes.  What you want is probably something like exec from linux.  On windows, your best bet is probably to do a WinAPI call.  eg: create process.

Offline Botsareus

  • Society makes it all backwards - there is a good reason for that
  • Bot God
  • *****
  • Posts: 4483
    • View Profile
    • DJ Paul Kononov
Re: Serios bug in vb6, or is it?
« Reply #3 on: February 02, 2014, 09:48:18 AM »
Oh, ok. Thank you.

Offline Botsareus

  • Society makes it all backwards - there is a good reason for that
  • Bot God
  • *****
  • Posts: 4483
    • View Profile
    • DJ Paul Kononov
Re: Serios bug in vb6, or is it?
« Reply #4 on: February 02, 2014, 10:46:38 AM »
Damn, still does not work.
I am using:
Code: [Select]

Public Sub SuperShell(pname As String)
Dim pInfo As PROCESS_INFORMATION
         Dim sInfo As STARTUPINFO
         Dim sNull As String
         Dim lSuccess As Long
         Dim lRetValue As Long

         sInfo.cb = Len(sInfo)
         lSuccess = CreateProcess(sNull, _
                                 pname, _
                                 ByVal 0&, _
                                 ByVal 0&, _
                                 1&, _
                                 NORMAL_PRIORITY_CLASS, _
                                 ByVal 0&, _
                                 sNull, _
                                 sInfo, _
                                 pInfo)
End Sub

Do I need to declare anything differently?

Offline Botsareus

  • Society makes it all backwards - there is a good reason for that
  • Bot God
  • *****
  • Posts: 4483
    • View Profile
    • DJ Paul Kononov
Re: Serios bug in vb6, or is it?
« Reply #5 on: February 02, 2014, 11:48:40 AM »
It was a complete pain, but I got a work around. I am telling restarter to kill the process by path.