procedure TForm1.Edit1Exit(Sender: TObject);
var
f: Double
begin
try
f := StrToFloat((Sender as TEdit).Text);
except
on EConvertError do
begin
ShowMessage('非法数字!');
(Sender as TEdit).Text := '';
end;
end;
end;
var
f: Double
begin
try
f := StrToFloat((Sender as TEdit).Text);
except
on EConvertError do
begin
ShowMessage('非法数字!');
(Sender as TEdit).Text := '';
end;
end;
end;
解决方案 »
- DrawText wordBreak的问题
- 如何用Tchart控件中的Line曲线做到用一条曲线有折回效果?
- 求助:关于DELPHI的标题栏问题【续】
- 求Delphi 注册表操作,过程。。
- 2006年3月5号将离开工作了近两年的公司,惆怅,散分!(来者有分)
- 请问BDE如何打包安装?
- who can help me?please
- 在adoconnection中设置connectionstring访问access数据库,出现密码无效提示,内详!
- 此贴打不开——http://www.csdn.net/expert/topic/304/304367.shtm
- 如何在线程中使用OLE自动化---急急急!!!
- 如何设置button的属性,将几个button该成控件数组
- 请教:关于注册表的读写
var
f: Double;
begin
try
f := StrToFloat((Sender as TEdit).Text);
except
on E: EConvertError do
begin
ShowMessage('非法数字!');
(Sender as TEdit).Text := '';
end;
end;
end;
begin
if Edit2.Text<>'' then
begin
try
StrtoFloat(Edit1.Text);
except
Begin
Application.MessageBox('请输入合法的数字!','错误:',MB_OK);
Edit1.SetFocus;
//如果是onpress这里加一句 key:=char(0);
end;
end;
end;
end;
配全 if (Key in ['0'..'9','.','-']) then