谁有自定义异常的实例代码?多谢,一经试用成功,就给分。
解决方案 »
- spcomm onreceivedata事件有时没响应
- 求fastreport delphi2010版
- 如何判断我当前使用是哪个Excel文档?
- 请教:如何让一个控件在设计时和运行时一致?
- 很简单的的错误,可是俺看不出到底哪里错!大家帮忙看看。
- 高分求教!!数据集的删除问题,Up者皆有分相送,在线等待~~
- 请各位在企业(工厂)作信息化工作的GGJJ们帮忙只占用你们分钟30的时间,现在只能给100不够我会再加,UP有分
- 请问TScrollBar控件怎么用?
- 请问在winXP里该如何实现如下功能呢?
- cobi(我是小新,我只有五岁):你好!帮帮我吧!
- delphi7怎么没有报表控件栏?
- 如何编写通过代理服务器发送邮件?
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;type
TForm1 = class(TForm)
Edit1: TEdit;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;type
eageexception=class(exception)
public
data:integer;
constructor create(const msg:string;age:integer);
end;implementation{$R *.dfm}constructor eageexception.create;
begin
inherited create(msg);
data:=age;
end;procedure TForm1.Button1Click(Sender: TObject);
var
age:integer;
begin
try
age:=strtoint(edit1.Text );
if (age<=0) or (age>108) then
raise eageexception.create('输入的年龄无效',age);
except
on ex:eageexception do
showmessage('年龄为'+inttostr(ex.data )+',视为无效');
on econverterror do
showmessage('年龄应为整数');
end;
end;end.