?
Solved

VB6-Application Error when I end the program in Debug Mode

Posted on 2003-02-27
6
Medium Priority
?
214 Views
Last Modified: 2008-03-03
Hi,

   I am writing a program using several API calls, but I found that VB6 will have application error when I forced to end the program under debug mode.

Here are the error message :
VB6.exe - Application Error
The instruction at "0x0fa95681" referenced memory at "0x00ffff00", The memory could not be "read".

  Personally, I found that it is caused by the "incomplete" calls of windows API, so how can I solve this problem, as it will lose all the changes of codes after error.

Regards,
Thomas Cheung


0
Comment
Question by:thomascy
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 2

Expert Comment

by:dankennedy
ID: 8038862
I've run into this problem as well. You have to be very careful when programming with API calls in VB. I don't think there is any way around it other then saving your work before you do a test run...

You could also compile the code before running it, that way it won't crash VB if the program dies.

Hope that helps.
0
 
LVL 3

Expert Comment

by:Da_Weasel
ID: 8039836
Go to Tools>Options there is a option to set VB to automatically save your project each time you run it.   This way you don't lose your changes if the IDE crashes with the program.
0
 

Expert Comment

by:catalin_tata
ID: 8040175
I've run into this problem only when i change the WindowProc for a form using API.In this case the sollution was to change the WindowsProc back to the default, before close the program.How kind of API call do you have in your program?>
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Expert Comment

by:M.E.Pierce
ID: 8040988
you could add an Errorhandler to your code;

at the begining of each sub/function add:

<BEGIN CODE>
On Error Goto errhdlr
<END CODE>

at the end of each sub/function add:

<BEGIN CODE>
errhdlr:
Stop       'So you know what sub/function caused the error
(Call your cleanup routine here)
<END CODE>

If you want to do a hard stop, creat an error in the next line of code to be executed. Then Step through your cleanup routine.

If there is a hard error(ie. code execution stops in a sub/function without calling the errorhandler), comment that line out.


0
 
LVL 3

Accepted Solution

by:
Da_Weasel earned 300 total points
ID: 8042465
the problem with API (hard errors) is that VB Error handling doesn really work, or at least not in a reliable fashion.
Like catalin tata said, you have to watch your WinProc's...and carfully code anything that makes use of APIs.

Handling errors work a little different with API than VB code.
In VB you add a "On Error" statement and then wait for an error to happen, see what the error was, and handle it.
When using API you have to do your error handling (error prevetion is a better name) before calling them.  Verify all data that is being passed to them.  If the data being passed is coming from an unknown source then you should setup a test program that loops through all of the possible and even a few near impossible senarios, then write code to check and handle all of these situations.
0
 

Expert Comment

by:CleanupPing
ID: 8901002
thomascy:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
Experts: Post your closing recommendations!  Who deserves points here?
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question