怎样自动生成十位数:
要求:
     从0000000000开始到0000000001、0000000002、0000000003……

解决方案 »

  1.   

    var
      NS: Array of String;
      S: String;
      I: Integer;
    begin
      SetLength(NS, 11);
      for I := 0 to 10 do
      begin
        S := IntToStr(I);
        S := StringOfChar('0', 10-Length(S)) + S;
        NS[I] := S;
      end;
    end;————————————————————————————————————
    宠辱不惊,看庭前花开花落,去留无意;毁誉由人,望天上云卷云舒,聚散任风。
    ————————————————————————————————————
      

  2.   

    function ZBTRIM(S : string; StrLength, FOB: Integer) : string ;// 前位补零,后位补空
    var i,j : integer ;
    begin
      i:= length(s);
     if (i>=StrLength ) then
     begin
       result := Copy(s,1,StrLength) ;
       exit ;
     end
     else
     begin
       if FOB = 0 then
       begin
        for j := 1 to (StrLength-i) do
          s := '0' + Trim(s)  ;
         result := s ;
       end
       else
       begin
        for j := 1 to (StrLength-i) do
          s :=  s +' '  ;
         result := s ;
       end ;
     end ;
    end ;
    调用该函数,第一个参数为数值,如‘1’,‘2’,‘3’
    第二位为长度,如10
    第三位填入0
      

  3.   

    procedure TForm1.Button2Click(Sender: TObject);
    var
      i: integer;
      str: string;
    begin
    for i := 1000 to 1005 do
      begin
        showmessage(copy('0000000000',1,10-length(inttostr(i)))+inttostr(i));
      end;
    end;