function CheckIntPass(AValue: string): boolean; begin Result := true; try StrToInt(AValue); except ShowMessage('请输入整数'); Result := false; end; end;function CheckFloatPass(AValue: string): boolean; begin Result := true; try StrToFloat(AValue); except ShowMessage('请输入数值数据'); Result := false; end; end;
如果要限制输入的内容可以转化为integer类型的数据的话,可以在KeyPress等事件里面限制非0到9的按键操作就可以了
key=#0;
begin
Result := true;
try
StrToInt(AValue);
except
ShowMessage('请输入整数');
Result := false;
end;
end;function CheckFloatPass(AValue: string): boolean;
begin
Result := true;
try
StrToFloat(AValue);
except
ShowMessage('请输入数值数据');
Result := false;
end;
end;
判断在你要的范围内。