字符串'ab',输出'ab   '格式,后边加三个空格,怎么办?谢了!

解决方案 »

  1.   

    ShowMessage(Format('%s   ',['ab']) + IntToStr(Length(Format('%s   ',['ab'])))) ;
      

  2.   

    楼上的一定错了!
    这个好象用Format是完不成的!
      

  3.   

    if Length(s) < 5 then s := Format('%s   ',[s]) ;
      

  4.   

    liang_z(千山一刀之忍者神龟) : 你试试看 :)
      

  5.   

    procedure TFrmmain.Button1Click(Sender: TObject);
    var
      s : String ;
    begin
      s := 'ab' ;
      if Length(s) < 5 then s := Format('%s   ',[s]) ;
      ShowMessage(s + '    ' + IntToStr(Length(s))) ; //ab       5 
    end;
      

  6.   

    function myFormatStr(In:string):string;
    const
      s := '     ';
    var
      L : integer;
    begin
      L := Length(In);
      if L<5 then
        result := In + Copy(s,1,5-L);
    end;
      

  7.   

    if Length(s) < 5 then 
    while Length(s) < 5 do
    s := s + ' ' ;
      

  8.   

    借 liang_z(千山一刀之忍者神龟)  老师函数 :)function myFormatStr(In:string):string;
    begin
      if Length(In) < 5 then 
      while Length(In) < 5 do
      In := In + ' ' ;
      Result := In ;
    end; 
      

  9.   

    function myFormatStr(In:string):string;
    const
      s := '     ';
    var
      L : integer;
    begin
      L := Length(In);
      if L<5 then
        result := In + Copy(s,1,5-L)
      else
        result := Copy(In,1,5);
    end;
      

  10.   

    看到这个没有 回复人: hyrongg(grant) ( ) 信誉:100  2003-01-20 10:32:00  得分:0 
     
     
      我的意思是输出的字符串式定长的,比如前边的可能是3个,2个,但输出的都是5个长度。不够用空格补上!