Página 1 de 1

Validação de CPF

Enviado: 10 Ago 2007 01:34
por Maligno

Código: Selecionar todos

//**********************************************************
function ValidCPF(cCPF)
local cDigs := ""
local nSTot := 0
local d,i,k := 11
if (Len(cCPF) = 11 .and. Replicate(Left(cCPF,1),11) != cCPF)
   for d := 1 to 2
       for i := 8+d to 1 step -1
           nSTot += Val(SubStr(cCPF,i,1)) * (k-i)
       next
       cDigs += Str(if((nSTot %= 11) < 2, 0, 11-nSTot),1)
       nSTot := 0
       k++
   next
   return cDigs = Right(cCPF,2)
end
return .F.