function TFPrincipal.CaracterDNI(DNI: string): Char;
begin
if not((Length(DNI)> 8) or (Length(DNI)< 7)) then begin
if (DNI[1] = 'X') then begin
Result := Copy('TRWAGMYFPDXBNJZSQVHLCKET',StrToInt(copy(DNI,2,7)) mod 23+1,1)[1];
end
else Result := Copy('TRWAGMYFPDXBNJZSQVHLCKET',StrToInt(DNI) mod 23+1,1)[1];
end
else
begin
MessageDlg('El CIF o NIE es incorrecto!',mtinformation,[mbOK],0);
result := '#';
end;
end;