Results 1 to 10 of 10

Thread: the little X in the upper right hand corner

  1. #1

    Thread Starter
    Hyperactive Member badgers's Avatar
    Join Date
    Sep 1999
    Location
    Madison, WI USA
    Posts
    444

    PLEASE HELP ME

    Can I please ask what everyone else does to handle program terminations?
    I want my program to unload,kill, remove, and otherwise stop running any time someone hits the little X in the corner or some selects quit.
    My project has 4 forms in it. sometimes only 3 are loaded.
    When one gets loaded I keep it in memory so that the user can go back to it the way they left it.
    How can I handle the removal of all forms and stop the exe from running when any X gets hit or the user selects quit?
    thank you for your time and have a good day

  2. #2

    Thread Starter
    Hyperactive Member badgers's Avatar
    Join Date
    Sep 1999
    Location
    Madison, WI USA
    Posts
    444
    I would be very thankful for any advice on the subject.
    thank you for your time and have a good day

  3. #3
    Fanatic Member
    Join Date
    Mar 2000
    Location
    That posh bit of England known as Buckinghamshire
    Posts
    658

    Re : Unloading

    Badger,

    Create a global module. In this module create a sub, and do the following

    eg.

    sub myUnload()

    unload form1
    unload form2
    unload form3
    unload form4

    end sub

    in the unload events of yuor forms, insert code to kill and objects etc. then call myUnload()

    so in each of the forms unload events, do someting similar to

    private sub form_Unload(cancel as integer)

    set myobject = nothing

    myunload

    end sub

    Iain.

  4. #4

    Thread Starter
    Hyperactive Member badgers's Avatar
    Join Date
    Sep 1999
    Location
    Madison, WI USA
    Posts
    444
    thank you very much that helped me out a lot

  5. #5
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    This will always close all forms no matter what their names are:

    Private Sub Form_Unload(Cancel As Integer)
    Dim i As Integer
    'close all sub forms
    For i = Forms.Count - 1 To 1 Step -1
    Unload Forms(i)
    Next
    End Sub


  6. #6
    Fanatic Member
    Join Date
    Mar 2000
    Location
    That posh bit of England known as Buckinghamshire
    Posts
    658

    unloading without names

    kedaman,

    I have tried what you have suggested before, and the program went into a continous loop and stopped responding.

    However i see your point that it does allow you to unload any form without having to know the name.

    The folllowing method works without crashing.

    Code:
    Private Sub Form_Unload(Cancel As Integer)    
        Dim form As form
      
        For Each form In Forms
          Unload form
        Next
    End Sub
    Iain.

  7. #7
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    That code i wrote works fine in my apps. But if one or more of your apps crash with it, I will copy your version. But I wonder if there really is anything that differs from yours.

  8. #8
    New Member
    Join Date
    Mar 2000
    Posts
    6
    Public Sub UnloadAllForms()
    Dim Form As Form

    For Each Form In Forms
    Unload Form
    Set Form = Nothing
    Next Form
    End Sub


    crack

  9. #9
    Lively Member
    Join Date
    Mar 2000
    Location
    Lowestoft
    Posts
    91
    why dont you just do:

    private sub form_unload(cancel as integer)
    end
    end sub


    surely that would just terminate the whole thing easier, prolly not the best way but would certainly work!

  10. #10

    Thread Starter
    Hyperactive Member badgers's Avatar
    Join Date
    Sep 1999
    Location
    Madison, WI USA
    Posts
    444
    it was my understanding that end would not free up all the resources.

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