|
|
|
|
|
Dicas
|
|
Visual Basic (Validações)
|
|
|
Título da Dica: Validar e-mail
|
|
|
|
Postada em 14/8/2000 por Webmaster
webmaster@vbweb.com.br
Public Function isEmail(ByVal pEmail As String) As Boolean Dim Conta As Integer, Flag As Integer, cValido As String isEmail = 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 isEmail = True
End Function
|
|
|
|
|