本帖最后由 南方的人 于 2015-3-26 12:37 编辑 procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char);//只能输入Real 数据
var
c: integer;
begin
// 加入代码让edit1只能输入数字
if Key = '.' then <span style="background-color: rgb(255, 0, 255);"> //如果这里改为#110,就一个都不能输入,为什么这个是只能输入一个' . '呢?</span>
begin
for c := 1 to Length(TEdit(Sender).Text) do
begin
if TEdit(Sender).Text[c] = '.' then
Key := #0;
end;
end
else if Key = #13 then
Perform(WM_NEXTDLGCTL, 0, 0)
else if Key = #8 then
Key := #8
else if (Key < '0') or (Key > '9') then
Key := #0;
end;
求大神解释下
|