Ya puestos vamos a hacer el trabajo completo
Código Delphi
[-]
function Letra(Numero: Integer): string;
begin
Result:= copy('TRWAGMYFPDXBNJZSQVHLCKET',1 + numero mod 23,1);
end;
function EsCorrecto(NIF: String): Boolean;
var
Numero: Integer;
begin
Result:= FALSE;
if Length(NIF) >= 9 then
if TryStrToInt(Copy(NIF,1,Length(NIF)-1),Numero) then
Result:= Uppercase(Copy(NIF,Length(NIF),1)) = Letra(Numero);
end;
if EsCorrecto('12345678Z') then
ShowMessage('Correcto')
else
ShowMessage('Incorrecto');