Estou desenvolvendo um sistema em vb.net 2010. A solução contém cinco projetos, um EXE (Principal) e quatro DLL (Cadastro, Financeiro, Jurídico e Biblioteca). A Biblioteca.dll contém uma classe Utils com funções para validar CPF, encriptar Senha e outras. Referenciei a Biblioteca.dll no projeto Principal.exe. Quando chamo fValidaCPF(txtCPF.text) do Projeto Principal.exe é apresentado um erro “Expressão não é um método”.
'----------------------------------------------------------------------
'Projeto Principal.exe
'----------------------------------------------------------------------
Imports Biblioteca
Imports Biblioteca.Utils
Imports System.Windows.Forms
Public Class Principal
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
fValidaCPF(TextBox1.Text)
End Sub
End Class
'----------------------------------------------------------------------
'Projeto Biblioteca.dll
'Valida CPF
'----------------------------------------------------------------------
Public Function FValidaCPF(ByVal CPF As String) As Boolean
Dim i, x, n1, n2 As Integer
CPF = CPF.Trim
For i = 0 To dadosArray.Length - 1
If CPF.Length <> 14 Or dadosArray(i).Equals(CPF) Then
Return False
End If
Next
'remove a maskara
'If Len(CPF) > 11 Then
CPF = CPF.Substring(0, 3) + CPF.Substring(4, 3) + CPF.Substring(8, 3) + CPF.Substring(12)
'End If
For x = 0 To 1
n1 = 0
For i = 0 To 8 + x
n1 = n1 + Val(CPF.Substring(i, 1)) * (10 + x - i)
Next
n2 = 11 - (n1 - (Int(n1 / 11) * 11))
If n2 = 10 Or n2 = 11 Then n2 = 0
If n2 <> Val(CPF.Substring(9 + x, 1)) Then
MsgBox("O CPF informado não é válido. Verifique se digitou corretamente.", _
MsgBoxStyle.Information, "GA .Net Consultoria")
Return False
End If
Next
MsgBox("O CPF informado é válido.", _
MsgBoxStyle.Information, "GA .Net Consultoria")
Return True
End Function