procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char);
begin
if (pos('.',Edit1.Text)>0) and (Key='.') then //控制文本框内只能输入一个小数点
begin
Key:=#0;
exit;
end;
if not (Key in ['0'..'9','.',#8]) then //控制文本框内只能输入≥0的实数
Key:=#0;
end;
Delphi学习手记——控制文本框输入的字符类型
最新推荐文章于 2022-04-27 16:52:22 发布
本文介绍了一段Delphi代码,用于控制文本框内的输入,确保只允许输入非负实数,并限制小数点的数量为一个。这对于需要精确数值输入的应用场景非常有用。
1069

被折叠的 条评论
为什么被折叠?



