function NumericPrecCheck(compnentCaption,text:string;numericPrec:integer;maxLimit:Integer):string;
var
E: extended;
begin
Result:='';
try
text:=Trim(text);
E:=StrToFloat(text);
if E>maxInt then
begin
Result:=compnentCaption+'超過范圍'+inttostr(maxLimit)+', 請重新輸入!';
end;
if ( pos( '.', text ) <> 0 ) and ( length( text ) - pos( '.', text ) >numericPrec ) then
begin
Result:=compnentCaption+'只能精確到小數點後' + IntToStr( numericPrec ) + '位,請重新輸入!';
end
else
begin
Result:='格式正確';
end;
except
Result:=compnentCaption+'為數字,請重新輸入!';
end;
end;
摘自 edisonfeng