function TForm1.CodeToIsbn(isbn: string): string;
var
  count:integer;
  i:byte;
begin
  count:=0;
  isbn:=AnsiReplaceStr(isbn,'-',''
  for i:=10 downto 2 do
    count:=count+i*strtoint(isbn[14-i]);
    i:=count mod 11;
  result:=copy(isbn,4,9);
  case i of
  0: result:=result+inttostr(0);
  10: result:=result+'X';
  else result:=result+inttostr(11-i);
  end;
end;