My Applications don't close
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7

Thread: My Applications don't close

  1. #1
    Join Date
    Jun 2001
    Location
    Medellín - Antioquia,Colombia - SurAmerica
    Posts
    86

    My Applications don't close

    Hello Everyone...

    Partners I developed an application , but I want to close it, not close totally.
    What can to do?
    How I can know what control is still open?
    Thanks a lot..

    joseluisbz@bigfoot.com


    Please Response to:joseluisbz@bigfoot.com
    http://www.bigfoot.com/~joseluisbz

  2. #2
    Join Date
    Sep 2000
    Posts
    58

    Re: My Applications don't close

    You need to remove all references to objects that may have been opened.

    One way to do this, is when you have finished with an object, or when you want to close the app, add the following code for the object(s).

    if not(obj is nothing) then _
    set obj = nothing

    This code with de-reference the object. (remember, an app will not close while there is an object still active - of cause it is a bit more complicated than this, but if you are a beginner than this rule keeps you out of trouble.)


  3. #3
    Join Date
    Aug 1999
    Location
    India-Delhi
    Posts
    106

    Re: My Applications don't close

    In addition to reply from uni, you shouls also use END statement to shut the application. It is a common practice but I thought I should tell you.


    Santulan

  4. #4
    Join Date
    May 1999
    Location
    Omika, Japan
    Posts
    729

    Re: My Applications don't close

    You SHOULD NOT use "End" because it will close the program without releasing references etc.. i.e it doesnot close 'gracefully'

    First close all pointers to global objects etc. with set obj = nothing command as shown in other post and then

    Unload all the forms with some code like

    for i = 0 to forms.Count
    unload forms(i)
    next i





    RK

  5. #5
    Join Date
    Jul 2000
    Location
    Milano, Italy
    Posts
    7,726

    Re: Ravi si right

    Never use End.
    It is not a "common practice" but a "common mistake" (take this the soft way: you're in good company...but from now on, banish the "end" keyword from your vocabolary).



    Special thanks to Lothar "the Great" Haensler, Tom Archer, Chris Eastwood, TCartwright, Bruno Paris, Dr_Michael
    and all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

    The Rater
    ...at present time, using mainly Net 4.0, Vs 2010



    Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
    all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

  6. #6
    Join Date
    Jun 2001
    Location
    Medellín - Antioquia,Colombia - SurAmerica
    Posts
    86

    Re: My Applications don't close

    Hello:

    Never I used this code...
    Please send me a snippet of code showing how to I use it in real components or Database.


    Thanks...

    joseluisbz@bigfoot.com


    Please Response to:joseluisbz@bigfoot.com
    http://www.bigfoot.com/~joseluisbz

  7. #7
    Join Date
    Sep 2000
    Posts
    58

    Re: My Applications don't close

    'I hope the following code helps. I am using
    'an example that loads a file into
    'word (using the
    'word 8 or 9 object library).

    Private objwordapp as word.application
    Private objworddoc as word.document

    Private sub try()

    'The following code fragment will only attempt
    'to initialize the word objects if they have
    'not already be initialized. This
    'reduces processing time if the procedure
    'is being resused.

    '********************************
    If objwordapp is nothing Then _
    set objwordapp as new word.application

    If objworddoc is nothing Then _
    set objworddoc as new word.document
    '********************************

    'Load the document into the word application

    set objworddoc = objwordapp.documents.open(pathname)

    'When you have finished using the objects
    'remove all references. (In this
    'case I am using word objects which also
    'require a close and quit respectively).
    'By setting the objects to nothing, the
    'objects references are removed. If this is
    'not done, an application can
    'experience significant decreases in
    'performance, and in some cases fatal
    'memory errors. Remember VB is not like Java.
    'It does not have its own garbage collector,
    'a certain amount of memory handling is expected.

    '********************************
    If (not objwordapp is nothing) Then
    objword.Close
    set objwordapp = nothing
    End If

    If (not objworddoc is nothing) Then
    objwordapp.Quit
    set objworddoc = nothing
    End If
    '********************************

    End sub



Posting Permissions

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


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This a Codeguru.com survey!


On-Demand Webinars (sponsored)