CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Jun 2011

    vb6 crash on exit

    I have a legacy vb6 app that crashes on exit - both as an executable and in the IDE. I am currently unloading the forms (except the frmmain) in form_unload, releasing all the adodb recordsets, setting all the boundcollections = nothing, I have attempted to SetErrorMode SEM_NOGPFAULTERRORBOX in the form_terminate event and that has not stopped the error from occurring. I have also checked for subclasses being instantiated in my code and found none. I have checked into the components from outside MS that are used - they are the Componentone flexgrid 8 spelling 8 and componentOne sizer control. An extensive web and forum search has not turned up any known problems similar to mine for these controls. The issue does not seem to occur if I shut down the program before actually doing anything. However loading the bound controls seems to be near where the problem is rooted, in spite of repeatedly stepping with the debugger it seems that the start of the problem "moves around". The problem occurs with the programmatic exit, the "X" and the IDE "end" control
    The error message is
    The instruction at "0x77d042b8" referenced memory at "0x055c9028". The memory could not be "Read". The title in the error box is a tool tip (differing at different times) from inside my app

  2. #2
    Join Date
    Jan 2006
    Fox Lake, IL

    Re: vb6 crash on exit

    Probably not closing everything, and it's calling something that you have already closed. I've posted the correct sequence before. Last year? (No VB6 on the laptop)

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  3. #3
    Join Date
    Jun 2011

    Re: vb6 crash on exit

    It appears that the bug is dead, the kill was in 10 parts
    1) very carefully disposing of all objects
    2) confirming that each recordset was closed before it was set to nothing
    3) closing each form from the last forms close event
    4) set the last form .visible = false then called a timer for 1 second
    5) added a getout call to the bottom of the last forms unload event
    6) put the getout in a module
    7) added
    Private Declare Function SetErrorMode Lib "kernel32" ( _
       ByVal wMode As Long) As Long
    Private Const SEM_NOOPENFILEERRORBOX = &H8000&
    to the declarations in that module
    8) called that declaration with
    at the start of the getout sub
    9) confirmed that the last open form was closed
    10) included this code at the bottom of the getout sub to make sure it could close
        Dim tstart As Date
        tstart = TimeValue(Now())
        Dim i As Integer
        i = 0
        Do While (DateAdd("s", 3, tstart)) > TimeValue(Now())
            For i = 0 To 1000
                i = i + 1
            i = 0
    that last part was sorta the equivalent of driving wooden stake into its heart
    thank you all for the help you have given me - I'll try and pay it back when I can

  4. #4
    Join Date
    Jul 2001
    Sunny South Africa

    Re: vb6 crash on exit

    Thanx for your detailed explanation on your problem fix!

    Please mark your thread resolved

Tags for this Thread

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

On-Demand Webinars (sponsored)

We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.