Try // try to execute
{SomeCode}
Handle t // execute when an error occurs. Handle T has a specific error type.
{SomeCode}
End;
Try // try to execute
{SomeCode}
Finally // execute it in any way
{SomeCode}
End;
Example:
Try
Age: = StrToInt (Edit1.Text );
ShowMessage (Format ('Born in % d', [YearOf (Now)-Age]);
Except
On EConvertError do
Showmessage ('the input and edit box is not a valid number! ');
On ERangeError do
Showmessage ('The age value in the input and edit box is too large! ');
End;
Reserved Words on... Do is used to determine the exception type. Note that the statement after limit T must be included in a certain on... Do module, but cannot exist independently. This is another difference from finally.
Exception Handling
Try
// If a success or failure occurs, the finally statement is jumped into and executed.
Finally
End;
Try
// Skip into failed t to execute
Except t on e: Exception do
ShowMessage (e. Message );
End;
Http://hi.baidu.com/delphidiary/blog/item/7afa9680368156d2bc3e1eb9.html