例如我想生成000001,000002,000003.......010000  之间的号码并插入到数据库中如何写?000001  填在edit1    中     010000填在edit2中,点"生成"按钮自动生成数据并插入到adoquery1中

解决方案 »

  1.   

    for i := 1 to 10000 do
    begin
    s := '00000'+IntToStr(i);
    s := RightStr(s, 6); //s is what you want
    //add s to DB here
    end;uses Strutils;http://lysoft.7u7.net
      

  2.   

    var
    i,Num:integer;
    s:string;
    begin
    for i:=Inttostr(Edit1.text) to Inttostr(Edit2.text) do begin
    Num:=Length(Edit1.Text)-Length(IntToStr(i));
    case Num of 
    1: s:='0'+IntToStr(i);
    2: s:='00'+IntToStr(i);
    .
    .
    end;
    With Query do begin
    Edit;
    FieldByName('FileName').Value:=s;
    Post;
    end;
    end;
    end;
      

  3.   

    var
      i, j, edit1len: integer;
      sstr:string;
    begin
      edit1len:=length(edit1.text);
      for i:= strtoint(edit1.text) to  strtoint(edit2.Text) do
      begin
        with ADOQuery1 do
        begin
          sstr:='';
          for j:=0 to (edit1len - length(inttostr(i)) -1 ) do
            sstr:= sstr + '0';
          Insert;
          FieldByName('YourNumber').AsString:= sstr + inttostr(i);
          Post;
        end;
      end;