Results 1 to 10 of 10

Thread: Something's very wrong with my program

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2001
    Posts
    485

    Resolved [resolved]

    I need help desperately!

    My program, cant unload properly now.

    When running under VB, after clicking exit (Unload Me) or the big X, the form is gone, but the VB still in 'run' mode.

    In order for my main Form to terminate properly, I gotta click on my About button(frmAbout.show vbModal,Me) [which doesnt run any specific things in the Form_Load(frmAbout) section.] then close the about and then can exit the main form properly.

    Anyone ever experience this?? What's is wrong?

    It was OK earlier, and I cant trace back the problem now

    Harddisk
    Last edited by Harddisk; Oct 11th, 2005 at 04:53 AM.

  2. #2
    Frenzied Member markman's Avatar
    Join Date
    Nov 2000
    Location
    Florida.
    Posts
    1,197
    Check if a form calls frmAbout.Show vbModal at any other time in the program. I had a similar problem once. You can find it around here somewhere.
    retired member. Thanks for everything

  3. #3
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    do you load any forms somewhere? Like, do you Load frmAbout at some point, and then when you click on the about button, all it has to do is show?

    try this in the Form_UnLoad event :
    Code:
    For Each Form In Forms
      Set Form = Nothing
    Next
    see if that helps...
    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  4. #4
    Lively Member devmax's Avatar
    Join Date
    Mar 2001
    Posts
    67

    Cool

    there is just a little code to add :

    Code:
    Private Sub Form_UnLoad()
    END
    end sub
    and this will terminate the program whatever is happening
    All what you dream is codable - DevMaX

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2001
    Posts
    485
    Originally posted by markman
    Check if a form calls frmAbout.Show vbModal at any other time in the program. I had a similar problem once. You can find it around here somewhere.
    Nope. The only time frmAbout.Show vbModal, Me is executed, it's on the cmdAbout_Click event. Dont have any other opened forms as well.

    There are a total of 3 forms
    Code:
    frmMain -- frmFile (consists of Drive, Dir, File dialogs)
        \
       frmAbout (frmMain is able to terminate after clicking/opening this)
    The frmMain form can be terminated properly only if I ever click on the About button to call out frmAbout. As for frmFile, it does nothing, the frmMain still stuck there.

    Thanks

    Harddisk

    PS: I did a search on .show on my project folder, it only occurs on the frmMain form file. When I do another search in the file(frmMain) content, there are 2 occurances, which is frmAbout.Show, and frmFile.Show.
    Last edited by Harddisk; Mar 11th, 2001 at 05:41 PM.

  6. #6

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2001
    Posts
    485
    Originally posted by devmax
    there is just a little code to add :

    Code:
    Private Sub Form_UnLoad()
    END
    end sub
    and this will terminate the program whatever is happening
    Thanks, this one works like charm, but I still wondering why doesnt the Unload Me/frmMain works, like it used to earlier.

    <sigh>

    Harddisk

  7. #7
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431
    I'm sorry to disagree with devmax, but you should never used End if you want to exit a program gracefully. While end will cause the program to terminate, it often does not give VB enough time do it's housekeeping and what this means is that you may wind up with memory leaks. Rather than using End, just make sure that all forms are unloaded when you want to end. This can be easily accomplished with the following code
    Code:
    '***************************************************************************
    'Purpose: Unload all forms when the user is ending execution via the
    '         FormControlMenu.
    'Outputs: None
    '***************************************************************************
    
        Dim nNdx As Integer
        
        'When done forward, this sometimes gives subscript out of range errors
        For nNdx = Forms.Count - 1 To 0 Step -1
            Unload Forms(nNdx)
        Next
        
    End Sub

  8. #8
    PowerPoster Lethal's Avatar
    Join Date
    Oct 2000
    Location
    Ohio
    Posts
    2,496
    I've read in many articles that using "End", after all other forms have been released from memory, by setting each form to nothing, only benefits in the so called "House Keeping" at the end of a prog. Just my .02 cents...

  9. #9
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    Originally posted by Lethal
    I've read in many articles that using "End", after all other forms have been released from memory, by setting each form to nothing, only benefits in the so called "House Keeping" at the end of a prog. Just my .02 cents...
    correct Lethal, but using End by itself is not a very good idea...
    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  10. #10
    PowerPoster Lethal's Avatar
    Join Date
    Oct 2000
    Location
    Ohio
    Posts
    2,496
    Totally agree, just want to though in my thoughts, to use it AFTER all memory is released...Glad somebody agrees...

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