function AddByString(const ASTR: string; const ANUM: Integer = 1): string; function FillSpace(const ASTR: string; const ALEN: Integer): string; begin Result := ASTR; while (Length(Result) < ALEN) do begin Result := '0' + Result; end; end; var i, iLen: Integer; s: string; begin iLen := Length(ASTR); for i := iLen downto 1 do begin if not (ASTR[i] in ['0'..'9']) then Break; end; if i <> iLen then begin Result := LeftStr(ASTR, i) + FillSpace(IntToStr(StrToInt(RightStr(ASTR, iLen - i)) + ANUM), iLen - i); end; end;
Inc(AddNum);
PiHao1Label:= Format('Sr_%d',[AddNum]);
PiHao2Label:= Format('Sr%d',[AddNum]);
如:由Sr350得到Sr351
'Sr' + IntToStr(StrToIntDef(RightStr('Sr350', 3), 0) + 1)
cut 自己写
呵呵
纯属灌水
等到要写的时候再str=前缀+inttostr(数字);
CR000001 加1 后应该是cr00002而不是cr2,
function FillSpace(const ASTR: string; const ALEN: Integer): string;
begin
Result := ASTR;
while (Length(Result) < ALEN) do
begin
Result := '0' + Result;
end;
end;
var
i, iLen: Integer;
s: string;
begin
iLen := Length(ASTR);
for i := iLen downto 1 do
begin
if not (ASTR[i] in ['0'..'9']) then
Break;
end;
if i <> iLen then
begin
Result := LeftStr(ASTR, i) + FillSpace(IntToStr(StrToInt(RightStr(ASTR, iLen - i)) + ANUM), iLen - i);
end;
end;