Pra que componente? É uma rotina muito simples. Pesquisei na internet e 
achei uma função pra validar PIS:

function TForm1.ConferePis(sPis: String): Boolean;
var i, iSoma, iAux, iDigito: Integer;
begin
   iSoma := 0;
   iAux := 2;
   for i := 1 to 10 do
   begin
      iSoma := iSoma + (iAux * StrToInt(Copy(sPis, 11-i, 1)));
      if iAux < 9 then
         iAux := iAux+1
      else
         iAux := 2;
   end;

   iDigito := 11 - (iSoma mod 11);
   if iDigito > 9 then
      iDigito := 0;

   Result := StrToInt(Copy(sPis, 11, 1)) = iDigito;
   if not Result then
      MessageDlg('Pis inválido!', mtWarning, [mbOK], 0);
end;


Eu tenho essa outra pra conferir CPF. Eu chamo no evento OnExit do 
componente:

function ConfereCPF(Edit : TCustomEdit) : Boolean;
var n1,n2,n3,n4,n5,n6,n7,n8,n9,d1,d2: Integer;
    Digitado, Calculado, Num : String;
begin
    ConfereCpf := True;
    Num := Edit.Text;
    Num := StringReplace(Num, '.', '', [rfReplaceAll]);
    Num := StringReplace(Num, '-', '', [rfReplaceAll]);
    Num := StringReplace(Num, '_', '', [rfReplaceAll]);

    if (Trim(Num) <> '') then
    begin
        n1 := StrToInt (Num[1]);
        n2 := StrToInt (Num[2]);
        n3 := StrToInt (Num[3]);
        n4 := StrToInt (Num[4]);
        n5 := StrToInt (Num[5]);
        n6 := StrToInt (Num[6]);
        n7 := StrToInt (Num[7]);
        n8 := StrToInt (Num[8]);
        n9 := StrToInt (Num[9]);

        d1 := n9*2+n8*3+n7*4+n6*5+n5*6+n4*7+n3*8+n2*9+n1*10;
        d1 := 11 - (d1 mod 11);

        if (d1 >= 10) then
            d1 := 0;

        d2:=d1*2+n9*3+n8*4+n7*5+n6*6+n5*7+n4*8+n3*9+n2*10+n1*11;
        d2:=11-(d2 mod 11);

        if (d2 >= 10) then
            d2:=0;

        Calculado := IntToStr(d1) + IntToStr (d2);
        Digitado := Num[10] + Num[11];
        ConfereCpf := Calculado = Digitado;
        if (Calculado <> Digitado) then
        begin
           Edit.SetFocus;
           raise exception.Create('CPF não confere!');
        end;
    end;
end;


__________________________________________________
Faça ligações para outros computadores com o novo Yahoo! Messenger 
http://br.beta.messenger.yahoo.com/ 

Responder a