![]() |
|
|
#1
|
|||
|
|||
|
Здравствуйте! Я создал програмку для обнаружения ошибки деления на ноль!
Вот код: Код:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
a,b:Double;
begin
try
a:=0;
b:=10/a;
if b>0 then
exit;
except
on EInOutError do
begin
ShowMessage('InOutError');
end;
on e:EZeroDivide do
begin
ShowMessage('ZeroDivideError :: '+e.Message);
end;
else
ShowMessage('AnotherError');
end;
end;
end.Вот содержание этого сообщения: Project Project1.exe raised exception class EZeroDivide with message 'Floating pointdivision by zero'. Process stopped. Use step or run to continue. Подскажите, что я не так делаю? Заранее спасибо за ответ! |
|
#2
|
|||
|
|||
|
Выполнять не из среды Дельфи, а из оси. Отладчик Дельфей отлавливает все исключения и показывает их первым.
|
|
#3
|
|||
|
|||
|
Большое спасибо, все получилось!
|