张志峰的博客

水滴石川,积少成多。

导航

Delphi 使用 Format格式话字符串的用法

Posted on 2013-11-25 15:58  ╰★张志峰★╮  阅读(551)  评论(0编辑  收藏  举报

 

找出以前的代码,写个随笔, 又想起以前的公司和以前的同事来, 希望以前的公司和同事事事顺意。

//返回格式化的字符串
function TfrmLedgerExVoucherLoad.GetFormatMonth(Month: Integer): string;
begin
if Month < 10 then
Result := format('%.2d', [Month])
else
Result := IntToStr(Month);
end;

 

 

{-------------------------------------------------------------------------------
过程名: getBackStr
作者: 张志峰
日期: 2010.11.25
参数: jInc: Integer
返回值: string
说明: 得到生成级次码的最后几位 jInc: 生成级次码后几位的数字
-------------------------------------------------------------------------------}

Function getBackStr(jInc: Integer): string; //
begin
Result := '';
if jInc < 10000 then
Result := Format('%.4d', [jInc]);
end;