OnEdit1Exit 事件中加以下代码:Try
StrToFloat(Edit1.Text);
Except
On EConvertError do
begin
Edit1.Text:='0';
Edit1.SetFocus;
end;
end;如果你用的数据表,还是用 DBEdit 吧,不用这么麻烦!
StrToFloat(Edit1.Text);
Except
On EConvertError do
begin
Edit1.Text:='0';
Edit1.SetFocus;
end;
end;如果你用的数据表,还是用 DBEdit 吧,不用这么麻烦!
解决方案 »
- 请问 WebBrowser 如何 忽略 _blank 直接在本WebBrowser中浏览?
- 用delphi 怎么调用用C#写的webservice?
- DELPHI下内嵌汇编int22这个中段指令要用什么代替了,操作系统是2K
- 怎样导出的问题
- 难难啊,怎样处理这样的数组?
- 如何使用TXMLTransformClient控件删除或增加数据库的信息!
- 打开窗体出现的问题
- 去找DELPHIDE的工作,自己一般编个什么程序去面试??
- 奇怪,奇怪,一个关于TNMUDP的问题
- 怎样知道当前窗口是那个EXE文件运行时创建的?
- 請問怎樣在沒有安裝DELPHI的機器上運行DELPHI應用程序﹖是不是一定要做成安裝文件﹖望傾囊相助﹗謝謝﹗
- 请问Indy控件组里的TCPServer、TCPClient控件怎样解决代理服务器的问题,进行局域网内、外的连接?
onkeypress
if not (key in ['0'..'9']) then
begin
edit1.text:='0';
edit1.setfocus;
end;
procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char);
begin
If Not (Key in ['0'..'9']) Then Key:=Chr($0);
end;
procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char);
begin
If Not (Key in ['0'..'9','.']) Then
begin
Key:=#0;
beep;
showmessage('只能输入数字')。
end;
end;
begin
try
strtofloat((sender as tedit).text);
except
(sender as tedit).text:='0';
(sender as tedit).setfocus;
end;end;procedure TForm1.Edit1Exit(Sender: TObject);
begin
Isnumber(sender as tedit);
end;
begin
Edit1.Text:=Inttostr(StrtointDef(Edit1.text,0));
end;
StrToFloat(Edit1.Text);
Except
Edit1.Text:='0';
Edit1.SetFocus;
end;不让他输入其他就行,呵呵,也不用报错提示什么的。
if not (key in ['0'..'9',#8]) then
begin
edit1.text:=inttostr(0);
edit1.setfocus;
end;
收工。
StrToFloat(Edit1.Text);
Except
On EConvertError do
begin
Application.MessageBox('请输入数字!','系统提示',mb_ok+mb_information); //最好给个提示,让用户知道自己为什么输入非法数据
Edit1.Text:='0';
Edit1.SetFocus;
end;
end;
StrToIntDef(Edit1.text,0);
1、StrToIntDef(Edit1.text,0);
2、在KeyPress事件中加入以下代码
If Not (Key in ['0'..'9']) Then Key:=Chr($0);