Results 1 to 29 of 29

Thread: Program not ending

Threaded View

  1. #4
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Program not ending

    Here is my routine that exits a program properly, after closing all forms and releasing all objects.
    VB Code:
    1. Private Sub ExitProgram_Click()
    2.   Dim frm As Form
    3.   Dim obj As Object
    4.   If InventoryDeducted = False Then Call  CloseInv ' If Necessary !
    5.   For Each frm In Forms
    6.      If frm.Name <> Me.Name Then ' Unload this form LAST
    7.        For Each obj In frm
    8.          On Error Resume Next
    9.            Unload obj
    10.            Set obj = Nothing
    11.        Next
    12.        Unload frm
    13.        Set frm = Nothing
    14.      End If
    15.     Next
    16.     On Error Resume Next
    17.       For Each obj In frm
    18.         Unload obj
    19.         Set obj = Nothing
    20.       Next
    21.      Set frm = Nothing
    22.      Unload Me
    23. End Sub
    Last edited by dglienna; Apr 19th, 2005 at 02:27 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width