我想输出一整数,定长5位,不足5位的加前导零补足。我这样写:
S:=Format('%5d',[123]);但得不到想要的结果,请大家帮忙看看,问题出在那里?
谢谢!

解决方案 »

  1.   

    S:=Format('%5.5d',[123]);
    这样你要的前导零就有了,注意s是一个string。
    你的问题在于没有定义其精度。
      

  2.   

    To caohonglong:
    成功了,谢谢!不过我对参数不大明白,'%5d'不是已经定义了长度必须是5吗?
    可以赐教吗?
      

  3.   

    楼主:其实最好的参考就是delphi的帮助。很多问题你都可以在那儿找到答案
      

  4.   

    function Format(const Format: string; const Args: array of const): string;This example displays a message on the form抯 status bar indicating the table record count after a record is deleted.procedure TForm1.Table1AfterDelete(DataSet: TDataSet);
    begin
      StatusBar1.SimpleText := Format('There are now %d records in the table', [DataSet.RecordCount]);
    end;