What happens if form does not unload?


I am new to VB6 and cannot find anything about my question in a book or the web.

I have a button on a windows form named "Finished" when pressed it calls the method
cmdOk_Click shown below.

Mostly this is a question about logic. In the code stub below if the subroutine
call to "SaveSuccesful" returns a true value then the "Unload Me" is executed.

So if it is Not executed then what happens? Does the windows form just stay open?



Private Sub cmdOK_Click()
  If (SaveSuccesful) Then _
  Unload Me
End Sub
LVL 2
brgdotnetcontractorAsked:
Who is Participating?
 
SriVaddadiCommented:
Yes. it remains. it remains in memory if u hide it or window is available visible
0
 
MattiCommented:
Hi!

Your program stays in memory.

Try this when you end your program:
Dim aForm As Form
For Each aForm In Forms
Unload aForm
Next

Regards!
Matti
0
 
VBClassicGuyCommented:
If I understand you correctly, in your exit routine I would give user a choice, or you'll never exit the program unlees the save is successful. Try:
Private Sub cmdOK_Click()
   Dim booSuccess As Boolean
   
Retry:
   booSuccess = SaveSuccesful()
   
   If booSuccess Then
      Unload Me
   Else
      Select Case MsgBox("Save failed!", vbAbortRetryIgnore, "ERROR")
         Case 3
            Rem *** Abort ***
            Exit Sub
         Case 4
            Rem *** Retry ***
            GoTo Retry
         Case 5
            Rem *** Ignore ***
            Unload Me
      End Select
   End If
   
End Sub
0
 
brgdotnetcontractorAuthor Commented:
Actually Srivadi had the best answer.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.