VALIDACAO DE CPF
                    Bom dia pessoal!!
Tipo estou criando uma função para validação de CPF, a qual recebe o numero do CPF por uma textbox e ela chama a seguinte função:
Mas ele retorna o seguinte erro: Compile Error: Type mismatch: array or user-defined type expected
Será quem alguem pode me ajudar?
            Tipo estou criando uma função para validação de CPF, a qual recebe o numero do CPF por uma textbox e ela chama a seguinte função:
Function ValidaCPF(CPF() As String) As Boolean
Dim Digito1(), Digito2(), SomaDigito As Integer
Dim DV1, DV2 As Integer
Dim i, resto As Integer
    [ô]Calcular 1º dÃgito
    Digito1(0) = CPF(0) * 10
    Digito1(1) = CPF(1) * 9
    Digito1(2) = CPF(2) * 8
    Digito1(3) = CPF(3) * 7
    Digito1(4) = CPF(4) * 6
    Digito1(5) = CPF(5) * 5
    Digito1(6) = CPF(6) * 4
    Digito1(7) = CPF(7) * 3
    Digito1(8) = CPF(8) * 2
    
    SomaDigito = 0
    
    For i = 0 To 8
        SomaDigito = SomaDigito + Digito1(i)
    Next i
    
    resto = SomaDigito Mod 11
    
    If resto < 2 Then
        DV1 = 0
    Else
        DV1 = 11 - resto
    End If
    
    [ô]Calcular 2º dÃgito
    Digito2(0) = CPF(0) * 11
    Digito2(1) = CPF(1) * 10
    Digito2(2) = CPF(2) * 9
    Digito2(3) = CPF(3) * 8
    Digito2(4) = CPF(4) * 7
    Digito2(5) = CPF(5) * 6
    Digito2(6) = CPF(6) * 5
    Digito2(7) = CPF(7) * 4
    Digito2(8) = CPF(8) * 3
    Digito2(9) = CPF(9) * 2
    
    SomaDigito = 0
    
    For i = 0 To 9
        SomaDigito = SomaDigito + Digito2(i)
    Next i
    
    resto = SomaDigito Mod 11
    
    If resto < 2 Then
        DV2 = 0
    Else
        DV2 = 11 - resto
    End If
    
    If CPF(9) = DV1 And CPF(10) = DV2 Then
        ValidaCPF = True
    Else
        ValidaCPF = False
    End If
End FunctionMas ele retorna o seguinte erro: Compile Error: Type mismatch: array or user-defined type expected
Será quem alguem pode me ajudar?
                    Simples, o Parametro esta declarado com array e voce esta passando string Simples...
tente essa abaixo :
ou ainda essa..
Abraços
            tente essa abaixo :
Public Function FU_ValidaCPF(CPF As String) As Boolean
Dim soma As Integer
Dim Resto As Integer
Dim I As Integer
[ô][ô]Valida argumento
If Len(CPF) <> 11 Then
FU_ValidaCPF = False
Exit Function
End If
soma = 0
For I = 1 To 9
soma = soma + Val(Mid$(CPF, I, 1)) * (11 - I)
Next I
Resto = 11 - (soma - (Int(soma / 11) * 11))
If Resto = 10 Or Resto = 11 Then Resto = 0
If Resto <> Val(Mid$(CPF, 10, 1)) Then
FU_ValidaCPF = False
Exit Function
End If
soma = 0
For I = 1 To 10
soma = soma + Val(Mid$(CPF, I, 1)) * (12 - I)
Next I
Resto = 11 - (soma - (Int(soma / 11) * 11))
If Resto = 10 Or Resto = 11 Then Resto = 0
If Resto <> Val(Mid$(CPF, 11, 1)) Then
FU_ValidaCPF = False
Exit Function
End If
FU_ValidaCPF = True
End Functionou ainda essa..
Public Function isCPF(ByVal pCPF As String) As Boolean
    
    Dim Conta As Integer, Soma As Integer, Resto As Integer, Passo As Integer
    
    isCPF = False: pCPF = Trim(pCPF)
    
    If Len(pCPF) <> 11 Then
        Exit Function
    End If
    
    For Passo = 11 To 12
        Soma = 0
        For Conta = 1 To Passo - 2
            Soma = Soma + Val(Mid(pCPF, Conta, 1)) * (Passo - Conta)
        Next
        
        Resto = 11 - (Soma - (Int(Soma / 11) * 11))
        
        If Resto = 10 Or Resto = 11 Then Resto = 0
        
        If Resto <> Val(Mid(pCPF, Passo - 1, 1)) Then
            Exit Function
        End If
    Next
    
    isCPF = True
End Function
 
[ô] como utilizar
 
Private Sub Command1_Click()
If isCPF(Text1.Text) = True Then
MsgBox [Ô]CPF é válido[Ô], vbInformation
Else
MsgBox [Ô]CPF é inválido![Ô], vbCritical
End If
End SubAbraços
                    Blz! Agora eu to ligado!! Vlw!!!
                
            
                        Tópico encerrado , respostas não são mais permitidas
                    
                
