如何让字符串'001003'加1成为'001004'
新字符串:=max(老字符串)+1

解决方案 »

  1.   

    function GetIncStr(str:string):string;
    var
      d:integer;
    begin
      result:=Format('%.6d',[1+strtoint(str)]);
    end;procedure TForm1.Button1Click(Sender: TObject);
    begin
      showmessage(getincstr('001003'));
    end;
      

  2.   

    function IntStrInc(AValue: AnsiString): AnsiString;
    var
      iLen: Integer;
    begin
      iLen := Length(AValue);
      if iLen = 0 then iLen := 1;  Result := Format('%.'+IntToStr(iLen)+'d',[StrToInt64Def(AValue,0)+1]);
    end;
      

  3.   

    function GetMax(str: string): string;
    var
      i:integer;
    begin
      i := StrToIntDef(str,0);
      Result := Format('%.6d',[1+i]);
    end;
      

  4.   

    ……
    Format('%.*d', [iLen, StrToInt64Def(AValue,0)+1]);