Thema: Delphi string inkrementieren

Einzelnen Beitrag anzeigen

Benutzerbild von Neutral General
Neutral General

Registriert seit: 16. Jan 2004
Ort: Bendorf
5.219 Beiträge
 
Delphi 10.2 Tokyo Professional
 
#3

AW: string inkrementieren

  Alt 1. Jun 2011, 10:04
merk dir wie viele Stellen der Barcode hatte. Dann umwandeln, erhöhen und dann mit Format und führenden 0en zurückwandeln.

Delphi-Quellcode:
function IncCode(Code: String): String;
var len: Integer;
    Val: Integer;
begin
  len := Length(Code);
  Val := StrToInt(Code);
  inc(Val);
  Result := Format('%.'+IntToStr(Len)+'d',[Val]);
end;
Michael
"Programmers talk about software development on weekends, vacations, and over meals not because they lack imagination,
but because their imagination reveals worlds that others cannot see."
  Mit Zitat antworten Zitat