edit编辑框只能输入数字和一个小数点
2011-07-05 19:44 李龙江 阅读(366) 评论(0) 编辑 收藏 举报procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char);
begin
ifnot(Key in [#48 .. #57, #8, #46]) then//#48-#57[0-9],#8[删除键],#49[小数点]
Key := #0; //#0[什么也不做]
begin
ifnot(Key in [#48 .. #57, #8, #46]) then//#48-#57[0-9],#8[删除键],#49[小数点]
Key := #0; //#0[什么也不做]
if (Key ='.') and (pos('.', Edit1.Text) >0) then
Key := #0;
end;
Key := #0;
end;