VoyForums
[ Show ]
Support VoyForums
[ Shrink ]
VoyForums Announcement: Programming and providing support for this service has been a labor of love since 1997. We are one of the few services online who values our users' privacy, and have never sold your information. We have even fought hard to defend your privacy in legal cases; however, we've done it with almost no financial support -- paying out of pocket to continue providing the service. Due to the issues imposed on us by advertisers, we also stopped hosting most ads on the forums many years ago. We hope you appreciate our efforts.

Show your support by donating any amount. (Note: We are still technically a for-profit company, so your contribution is not tax-deductible.) PayPal Acct: Feedback:

Donate to VoyForums (PayPal):

Login ] [ Contact Forum Admin ] [ Main index ] [ Post a new message ] [ Search | Check update time ]
Subject: Re: visual basic


Author:
Tilleman Kristof
[ Next Thread | Previous Thread | Next Message | Previous Message ]
Date Posted: 10:28:58 03/11/02 Mon
In reply to: Stijn Exter 's message, "visual basic" on 09:30:12 03/10/02 Sun

Ik vond het onderstaande in de help van visual basic:


Exceptions: Catching and Deleting Exceptions
Home | Overview | How Do I | FAQ

The following instructions and examples show you how to catch and delete exceptions. For more information on the try, catch, and throw keywords.

Your exception handlers must delete exception objects they handle, because failure to delete the exception causes a memory leak whenever that code catches an exception.

Your catch block must delete an exception when:

The catch block throws a new exception.
Of course, you must not delete the exception if you throw the same exception again:

catch(CException* e)
{
if (m_bThrowExceptionAgain)
throw; // Do not delete e
}

Execution returns from within the catch block.
Note When deleting a CException, use the Delete member function to delete the exception. Do not use the delete keyword, because it can fail if the exception is not on the heap.

To catch and delete exceptions

Use the try keyword to set up a try block. Execute any program statements that might throw an exception within a try block.
Use the catch keyword to set up a catch block. Place exception-handling code in a catch block. The code in the catch block is executed only if the code within the try block throws an exception of the type specified in the catch statement.

The following skeleton shows how try and catch blocks are normally arranged:

// Normal program statements
...

try
{
// Execute some code that might throw an exception.
}
catch( CException* e )
{
// Handle the exception here.
// "e" contains information about the exception.
e->Delete();
}

// Other normal program statements
...

When an exception is thrown, control passes to the first catch block whose exception-declaration matches the type of the exception. You can selectively handle different types of exceptions with sequential catch blocks as listed below:

try
{
// Execute some code that might throw an exception.
}
catch( CMemoryException* e )
{
// Handle the out-of-memory exception here.
}
catch( CFileException* e )
{
// Handle the file exceptions here.
}
catch( CException* e )
{
// Handle all other types of exceptions here.
}

For related information, see Exceptions: Converting from MFC Exception Macros.

[ Next Thread | Previous Thread | Next Message | Previous Message ]

Replies:
Subject Author Date
Re: Re:visual basicStijn Exter09:49:09 03/12/02 Tue


Post a message:
This forum requires an account to post.
[ Create Account ]
[ Login ]
[ Contact Forum Admin ]


Forum timezone: GMT-8
VF Version: 3.00b, ConfDB:
Before posting please read our privacy policy.
VoyForums(tm) is a Free Service from Voyager Info-Systems.
Copyright © 1998-2019 Voyager Info-Systems. All Rights Reserved.