Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 217
  • Last Modified:

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

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
thomascy
Asked:
thomascy
1 Solution
 
dankennedyCommented:
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
 
Da_WeaselCommented:
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
 
catalin_tataCommented:
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
Industry Leaders: 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!

 
M.E.PierceCommented:
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
 
Da_WeaselCommented:
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
 
CleanupPingCommented:
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

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now