如何将类似20。00或。12 的书转换成10位长的串如:0000002000或0000000012(50分)

  • 主题发起人 主题发起人 lili365
  • 开始时间 开始时间
L

lili365

Unregistered / Unconfirmed
GUEST, unregistred user!
请给个提示
 
Function IntAddZero60(Source: Integer; SetLength: Integer): String;
const
Zero: String='000000000000000000000000000000000000000000000000000000000000';
var
StrLen: Integer;
TempS: String;
Begin
TempS:=IntToStr(Source);
StrLen:=Length(TempS);
if StrLen>=SetLength then
Result:=Copy(TempS, 1, SetLength)
else
Result:=Copy(Zero,1, SetLength-StrLen)+TempS;
End;

这样调用即用
IntAddZero60(yourvalue*100, 10);
 
FormatFloat('0000000000',YourNum)
 
function convertchar(value:float):string
begin
if value-trunc(value)>0 then value:=value*100;
result:=copy('0000000000',1,10-length(inttostr(value)))+inttostr(value);
end;
 
如balaschen
FormatFloat('0000000000',YourNum*100)

or

Format('%10.10d',[Round(num*100)])
 
多人接受答案了。
 
后退
顶部