Click to See Complete Forum and Search --> : What determines the value of App.PrevInstance?
Colleen
July 21st, 1999, 07:15 AM
I've got this code in my program
If App.PrevInstance then
MsgBox "A previous instance running"
End
End If
If I run the exe, exit the program, then restart the program I get the prev instance message. This is happening even when I am the only one running the program. So, I figure something must be left open when I exit the program. How can I found out what is causing App.Prev.Instance to be true?
Thanks for the help!!
Lothar Haensler
July 21st, 1999, 07:39 AM
in NT use the Task-Manager (Ctrl+Alt+Del - Task-Manager) to check whether your program is still running after you try to end it.
make sure that you unload all your forms when you try to end your program.
When all else fails, use the End statement to end your program.
Jan Businger
July 21st, 1999, 09:59 AM
Hi,
I agree with Lothar; you must be sure that no form still hangs around in memory.
Closing elegantly your application and to be informed what's going on you can do a.o. the following:
Put code in the FormQueryUnload , I anticipate you have also a MDI Form. so:
////////////////////////////////////////
Private Sub MDIForm_QueryUnload(Cancel As Integer, UnloadMode As Integer)
'Code taken from Inside VB, 9705 issue
Dim intAns As Integer
Dim strMode As String
Select Case UnloadMode
Case 0
strMode = "Close from control menu"
Case 1
strMode = "Unload Keyword"
Case 2
strMode = "Windows session is ending"
Case 3
strMode = "TaskManager"
Case 4
strMode = "MDI Parent is closing"
End Select
intAns = MsgBox("Exit the programme?", 1 + 32, strMode)
If intAns = 1 Then
'CleanUpJobs
Unload Me
Else
Cancel = 1
End If
End Sub
////////////////////7
You can also force ALL child forms to be unloaded, this can be done in this phase of unloading
Private Sub MDI_FormUnload(Cancel as Integer)
Dim i as Long
For i = Forms.Count - 1 To 1 Step -1
Unload Forms(i)
Next i
Colleen
July 21st, 1999, 11:51 AM
Thanks Lothar.
I've unloaded all my forms and used the END statement.
Part of the problem is that I only get the error if I proceed far enough into the program. i.e. If I exit after a few screens, I get no error.
(I'm using VB 5 and MS Access.)
Colleen
July 21st, 1999, 12:23 PM
Thanks Jan.
I'll try that.
Part of the problem is that I only get the error if I proceed far enough into the program. i.e. If I exit after a few screens, I get no error.
(I'm using VB 5 and MS Access.)
I'm also using an FXVideo Control along with some standard VB controls. Is there any way of checking that one of my controls is not closing/unloading properly?
Thanks again.
Colleen
July 22nd, 1999, 05:54 AM
I don’t know if you have time to help me with this, but - here goes:
My program runs form VB5 with an Access database. Each screen is part of a specific node. The previous instance error only happens when:
1. I reached the last screen of a node
2. try to continue when there is not another screen after the current one (this triggers a beep sound)
3. exit program
4. restart program
‘Code to continue on to next screen
Case "GOTONEXT"
TipTimer.Enabled = False
FXVideo.Command = FX_CLOSE
If SetNext Then ‘I think this is where my problem is starting
Call ClearScrn
Call SetupScreen
Call StoreJumps
Else ’trigger sound
i= mciSendString("CLOSE SAMPLE", 0&, 0, 0)
i = mciSendString("OPEN " & GetWaveName(GetCommonText("Sound", "NoScreen")) & " ALIAS SAMPLE", 0&, 0, 0)
i = mciSendString("PLAY SAMPLE", 0&, 0, 0)
End If
Private Function SetNext() As Boolean
On Error GoTo SetNextErr
If Not RSNodeInfo.EOF Then
RSNodeInfo.MoveNext
Else
SetNext = False
Exit Function
End If
If RSNodeInfo.EOF Then
RSNodeInfo.MoveLast
SetNext = False
Exit Function
End If
SetNext = True
Exit Function
SetNextErr:
Select Case ErrorHandler
Case 3 ' Abort
End
Case 4 ' Retry
Resume
Case 5
Resume Next
End Select
End Function
Any ideas? I’m completely stumped.
Ravi Kiran
July 22nd, 1999, 06:05 AM
You say, that the err comes only if you do deep down in the program flow. So obviously your clean up procedure is not "clean".
Also you are not showing the sectoin that calls the SetNext fn
if SetNext then
.... You are calling 3 fns here
else
.. indicating the end to MCI player
end if
??? what are you doing here after this??
Are you undoing whatever is happening in those
"ClearScrn" , "SetupScreen" functions?
If you are using "End" command, just put this
small like before this and look at the debug print
Debug.print Forms.Count
It better print 1 otherwise use the code Jay said ahead in the thread
Ravi
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.