Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

project not closing completely

Status
Not open for further replies.

smithbr

MIS
May 29, 2003
85
0
0
US
I have a vb.net application that contains 2 forms. When I try to close the project, the form disappears, but the projct is still running....I have to hi tthe stop button to close it out all the way.

Here is the code I have to get to form2 and back to form1:
'To form2
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim frmfind As New DumbInvoice
frmfind.Show()
Me.Hide()

End Sub


'Back to Form1
Private Sub btnback_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnback.Click
Dim frmmain As New frmmarkpaid
frmmain.Show()
frmmain.txtinvnum.Text = lblinvfin.Text
Me.Close()

End Sub

Does anyone know what I have to do to get it to close out all the way.
 
Hi,
If you're trying to halt the execution of the entire program, just add "End" as the last command in btnBack_Click.

Ben
 
Of course I should note that the structure you're using can be improved by using the ShowDialogMethod:

'A cleaner way to open frmFind,
'Get its entry, and close the
'entire program

Private Sub Button1_Click(...) Handles ...
Dim frmfind As New DumbInvoice()
Me.Visible = False
'ShowDialog() freezes all other
'forms in this app until the user
'closes frmfind; then execution resumes
'at Me.Visible = True

frmfind.ShowDialog()
Me.Visible = True
txtinvnum.Text = frmfind.lblinvfin.Text
frmfind.Dispose()

'Shut down the entire app
End
End Sub
 
smithbr -

Make sure all your object references are being Disposed and/or set to nothing when you close your app. You might have some circular references (object A contains a reference to object B, which contains a reference to object A) in your code, and it will take the garbage collector a couple of extra runs to clean them up. In the meantime, the objects are still "alive".

Chip H.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top