#1
  1. Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2002
    Location
    Sweden
    Posts
    29
    Rep Power
    0

    How to exit a program


    I know it's kind of lame and such, but i still don't know, so i'm asking.
    What's the function to call when i want to quit my program?
    That is, which function should i connect to my "Quit" button in my program?
    I tried exit() and quit() but none of em worked, please help, i can't seem to find any help on this online either.

    Comments on this post

    • JimmyGosling agrees
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Apr 2002
    Posts
    693
    Rep Power
    26
    unload the form, and then end

    unload me
    end
  4. #3
  5. /(bb|[^b]{2})/

    Join Date
    Nov 2001
    Location
    Somewhere in the great unknown
    Posts
    5,163
    Rep Power
    792
    Be sure to unload all loaded forms before you call end.

    VB doesn't have the best memory management and calling end doesn't always clean the memory properly if there are still loaded forms present.
  6. #4
  7. Throws Rocks
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2002
    Location
    Cincinnati, Ohio
    Posts
    392
    Rep Power
    14

    Fully


    Remember you need to put an End command in the Form_Unload event as well. This is key.
    Last edited by GNUbie; November 10th, 2002 at 07:46 PM.
    Two things have come out of Berkeley, Unix and LSD.
    It is uncertain which caused the other.
  8. #5
  9. No Profile Picture
    Mc-Chin
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2001
    Posts
    86
    Rep Power
    13
    Hi All,

    Hope someone can provide more info on closing VB apps.

    I have an application with dozens of forms and child forms, and using over 20 OCXs...once compiled the exe is around 10 MBs..

    under development environment i can "End" the application properly....but when compiled and execute it, when i end the application, all the forms are gone, but under the "Task Management" utility in win2000 (CTRL + ALT + DEL) i can still see my app is running.


    in my MDI parent form_unlod, i use
    PHP Code:
        for each obj in forms
             Unload obj
        next

        end 
    but after some reading and etc... i used

    PHP Code:

    Public Declare Function FindWindow Lib "user32" Alias _
          
    "FindWindowA" (ByVal lpClassName As StringByVal _
          lpWindowName 
    As String) As Long
    Declare Function PostMessageByNumLib "user32" Alias _
        
    "PostMessageA" (ByVal hwnd As LongByVal wMsg As _
        Long
    ByVal wParam As LonglParam As Long)

    Const 
    WM_CLOSE = &H10
    Const TARGET_CLASS_NAME "ThunderRT6Main"
    Const TARGET_WINDOW_TEXT "Project1"

    ....Form Unload event (MDI parent)....
        for 
    each obj in forms
             Unload obj
        next


        hTarget 
    FindWindow(TARGET_CLASS_NAME TARGET_WINDOW_TEXT)
        
    ' The following line will close the app.
        ' 
    You could instead set up a subclasser here.
        
        If 
    hTarget Then Call PostMessageByNum(hTargetWM_CLOSE00)

        
    end 

    with the above, i can end the VB App.

    any comments?

    Thanks and Best Regards

    Comments on this post

    • JimmyGosling agrees

IMN logo majestic logo threadwatch logo seochat tools logo