We help IT Professionals succeed at work.

Exception error occurring when VB6 app shuts down

onemorecoke
onemorecoke used Ask the Experts™
on
I have an application that works fine most of the time, but under a unknown circumstance, when the application is shut down, I get an application error pop box that says "The instruction at 0x7c82a774 referenced memory at 0xffffffff. The memory could not be read".  This occurs when I have a button on the form that just has an "unload me", it is a single form application.  I am using ADO to access a database.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
C# ASP.NET Developer
Top Expert 2010
Commented:
Do you close your connections prior to shutdown?

Author

Commented:
Yes, I close it and send the connection to "nothing"

cn.close
set cn=Nothing

It is a real mystery for sure
Adam MenkesC# ASP.NET Developer
Top Expert 2010

Commented:
Do you happen to have a timer running in the app?

Author

Commented:
yes.  Actually, I put the button on the form with the unload just to see if just unloading or ending the application would cause the problem. What the application really does is start, run some database functions, and should close.  I found that if I put all the code in the form_load event, I could not end the program well.  So, the startup form has a timer on it.  Once the form is loaded, the timer fires.  The first thing the timer does is disable itself (Timer1.enabled=false).  Then the code in the timer is run, and when it is finished, it unloads.  I works most of the time so I am thinking it is some type of memory leak or shutdown timing issue.

Author

Commented:
Overall, it was a sequencing issue where a form was being closed and code was trying to be execute directly after it.  After moving code around it worked.