delphi
function EAN13(i: int64): String; var j: Integer; begin Result:= Format('%12.12d',[i]); j:= 0; while i > 0 do begin inc(j,(i mod 10) * 3); i:= i div 10; inc(j,i mod 10); i:= i div 10; end; Result:= Result + IntToStr((10 - (j mod 10)) mod 10); end; // Por ejemplo ShowMessage(EAN13(123456789012));
Y si el numero lo tenemos en una variable String, por ejemplo en un TEdit
delphi
ShowMessage(EAN13(StrToInt64(Edit1.Text)));