ter-pierre Posted February 13, 2006 Posted February 13, 2006 a dias atrás tive necessidade de fazer a verificação de um CPF. abaixo o código udsado: Func checaCPF ($NCPF2) $soma = 0 for $i=0 to 8 $soma = $soma + (Int(StringMid($NCPF2,$i+1,1)) * (10 - $i)) Next If $soma-(Int($soma/11)*11)<2 Then $1D=0 Else $1D=11-($soma-(Int($soma/11)*11)) EndIf If $1D<>StringLeft(StringRight($NCPF2,2),1) Then Return(0) $soma = 0; for $i=0 to 8 $soma = $soma + (Int(StringMid($NCPF2,$i+1,1)) * (11 - $i)) Next $soma=$soma+($1D*2) If $soma-(Int($soma/11)*11)<2 Then $2D=0 Else $2D=11-($soma-(Int($soma/11)*11)) EndIf If $2D<>StringRight($NCPF2,1) Then Return(0) Return(1) EndFunc Pierre
Angelo Júnior BR Posted October 23, 2008 Posted October 23, 2008 Boa tarde Pierre, Vi o seu código de Validação de CPF, porém não consegui utilizá-lo. Tem como você me passar maiores detalhes? Obrigado! Angelo
ter-pierre Posted November 12, 2008 Author Posted November 12, 2008 Boa tarde Pierre,Vi o seu código de Validação de CPF, porém não consegui utilizá-lo. Tem como você me passar maiores detalhes?Obrigado!AngeloChame a função informando o cpf, se for válido retorna 1 e se não for retorna 0.Exemplo:$CPF=InputBox("","CPF")If checacpf($CPF)=1 Then MsgBox(0,"","CPF OK")Else MsgBox(0,"","CPF inválido")EndIfExit
trancexx Posted November 12, 2008 Posted November 12, 2008 CPF = Cadastro de Pessoas Físicas ? ♡♡♡ . eMyvnE
ter-pierre Posted November 20, 2008 Author Posted November 20, 2008 CPF = Cadastro de Pessoas Físicas ?yes!
trancexx Posted November 20, 2008 Posted November 20, 2008 yes!Here's my try (hope you don't mind): Func _checaCPF($NCPF2) If StringLen($NCPF2) - 11 Then Return False EndIf Local $v1 For $i = 0 To 8 $v1 += Number(StringMid($NCPF2, $i + 1, 1)) * (10 - $i) Next $v1 = 11 - Mod($v1, 11) $v1 *= $v1 < 10 If Not $v1 = Number(StringMid($NCPF2, 10, 1)) Then Return False EndIf Local $v2 For $i = 0 To 8 $v2 += Number(StringMid($NCPF2, $i + 1, 1)) * (11 - $i) Next $v2 = 11 - Mod($v2 + 2 * $v1, 11) $v2 *= $v2 < 10 Return $v2 = Number(StringRight($NCPF2, 1)) EndFunc língua portuguesa - one of my favorites ♡♡♡ . eMyvnE
ter-pierre Posted February 17, 2009 Author Posted February 17, 2009 Legal! Obrigado pela colaboração.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now