```Array
(
)
```

# Como fazer a validação do cpf?

Connection
- 24 nov 2009

Bom dia a todos!   Preciso saber como faço para validar o cpf digitado pelo usuario?   Desde já agradeço!!!

Wilson Paulista...!!!
- 24 nov 2009

function CPF_Valido(strCPF: string): boolean;
var
sDigInfo, sDigCalc: String[2];
VetCPF: Array[1..11] of ShortInt;
fCPF: Extended;
wCPF_Total: Word;
x: ShortInt;
CodErro: Integer;
begin
Val( strCPF, fCPF, CodErro );
Str( fCPF :11 :0, strCPF );

for x := 1 to 11 do
begin
if  Length( Trim(strCPF[x]) ) = 0 then
VetCPF[x] := 0
else
VetCPF[x] := StrToInt( strCPF[x] )
{endif};
end;

sDigInfo := IntToStr( VetCPF[10] ) + IntToStr( VetCPF[11] );

wCPF_Total :=
( VetCPF[1] * 10 ) + ( VetCPF[4] * 7 ) + ( VetCPF[7] * 4 ) +
( VetCPF[2] *  9 ) + ( VetCPF[5] * 6 ) + ( VetCPF[8] * 3 ) +
( VetCPF[3] *  8 ) + ( VetCPF[6] * 5 ) + ( VetCPF[9] * 2 );

wCPF_Total := wCPF_Total - ( wCPF_Total div 11 * 11 );

if  wCPF_Total < 2 then
VetCPF[10] := 0
else
VetCPF[10] := 11 - wCPF_Total
{endif};

wCPF_Total :=
( VetCPF[1] * 11 ) + ( VetCPF[4] * 8 ) + ( VetCPF[7]  * 5 ) +
( VetCPF[2] * 10 ) + ( VetCPF[5] * 7 ) + ( VetCPF[8]  * 4 ) +
( VetCPF[3] *  9 ) + ( VetCPF[6] * 6 ) + ( VetCPF[9]  * 3 ) +
( VetCPF[10] * 2 );

wCPF_Total := wCPF_Total - ( wCPF_Total div 11 * 11 );

if  wCPF_Total < 2 then
VetCPF[11] := 0
else
VetCPF[11] := 11 - wCPF_Total
{endif};

sDigCalc := IntToStr( VetCPF[10] ) + IntToStr( VetCPF[11] );

Result := sDigCalc = sDigInfo
end;