假如 old_string:='P10005';
 怎样实现 new_string:='P10006';
           谢谢!

解决方案 »

  1.   

    new_string := Format('P%5.5d',[StrToInt(Copy(Old_String, 2, 5))+1]);
      

  2.   

    unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls;type
      TForm1 = class(TForm)
        Button1: TButton;
        procedure Button1Click(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;var
      Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
    var
     a:string;
     b:string;
     c:string;
     i:integer;
    begin
        a:= 'P10005';
        showmessage(a);
        b:=copy(a,1,5);
        c:=copy(a,6,1);
        i:=strtoint(c)+1;
        showmessage(b+inttostr(i));
    end;end.
      

  3.   

    stringReplace('p10005','5','6',[rfReplaceall]);
    newstring:='p'+inttostr(strtoint(RigtStr(oldstring,5))+1)
      

  4.   

    s1:string;
    s1:=midstr(old_str,2,5);
    s1:=inttostr(strtoint(old_str)+1);showmessage('p'+s1);