您的位置:首页 > 编程语言 > Delphi

Delphi之Raise抛出异常

2017-01-13 09:34 183 查看


相关资料:
http://blog.csdn.net/a20071426/article/details/10160171
实例代码:

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
int1: Integer;
begin
try
int1 := StrToInt('A');
except
raise Exception.CreateFmt('%d = %s',[1001, '您的程序在Unit1单元32行出错了!']);
end;
end;

end.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: