Estou usando a fuunção abaixo para validar email, mas ocorre um erro na linha: If Not (LCase(cValido) Like "[a-z]" Or cValido = "@" Or cValido = "." Or cValido = "-" Or cValido = "_") Then, mais precisamente nesta parte: LCase(cValido) Like "[a-z]".
O erro é:
Sub or Function not defined
Alguém sabe o que é?
Function EmailCorreto(pEmail)
Dim Conta, Flag, cValido
EmailCorreto = False
If Len(pEmail) < 5 Then
Exit Function
End If
'Verifica se existe caracter inválido
For Conta = 1 To Len(pEmail)
cValido = Mid(pEmail, Conta, 1)
If Not (LCase(cValido) Like "[a-z]" Or cValido = "@" Or cValido = "." Or cValido = "-" Or cValido = "_") Then
Exit Function
End If
Next
'Verifica a existência de (@)
If InStr(pEmail, "@") = 0 Then
Exit Function
Else
Flag = 0
For Conta = 1 To Len(pEmail)
If Mid(pEmail, Conta, 1) = "@" Then
Flag = Flag + 1
End If
Next
If Flag > 1 Then Exit Function
End If
If Left(pEmail, 1) = "@" Then
Exit Function
ElseIf Right(pEmail, 1) = "@" Then
Exit Function
ElseIf InStr(pEmail, ".@") > 0 Then
Exit Function
ElseIf InStr(pEmail, "@.") > 0 Then
Exit Function
End If
'Verifica a existência de (.)
If InStr(pEmail, ".") = 0 Then
Exit Function
ElseIf Left(pEmail, 1) = "." Then
Exit Function
ElseIf Right(pEmail, 1) = "." Then
Exit Function
ElseIf InStr(pEmail, "..") > 0 Then
Exit Function
End If
EmailCorreto = True
End Function