VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Validates Email ID

by Ganesh Thambiran (2 Submissions)
Category: String Manipulation
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Thu 24th February 2000
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Validates Email ID

Rate Validates Email ID



Public Function ValidateEmail(ByVal sEmail As String) As Boolean
  Dim m, n, o, i
  If InStr(sEmail, "@") > 0 Then
    For i = 1 To Len(sEmail)
      If InStr("[email protected]_", Mid(sEmail, i, 1)) > 0 Then
      Else
        ValidateEmail = False
        Exit Function
      End If
    Next i
    m = Split(sEmail, "@")
    If UBound(m) > 1 Then
      ValidateEmail = False
      Exit Function
    End If
    o = Split(m(0), ".")
    For i = 0 To UBound(o) ' - 1
      If Len(o(i)) < 1 Then
        ValidateEmail = False
        Exit Function
      End If
    Next i
    For i = 0 To UBound(m) - 1
      If Len(m(i)) < 2 Then
        ValidateEmail = False
        Exit Function
      End If
    Next i
    If InStr(m(1), ".") > 0 Then
      n = Split(m(1), ".")
      For i = 0 To UBound(n) ' - 1
        If Len(n(i)) < 2 Then
          ValidateEmail = False
          Exit Function
        End If
      Next i
    Else
      ValidateEmail = False
      Exit Function
    End If
  Else
    ValidateEmail = False
    Exit Function
  End If
  ValidateEmail = True
End Function



Download this snippet    Add to My Saved Code

Validates Email ID Comments

No comments have been posted about Validates Email ID. Why not be the first to post a comment about Validates Email ID.

Post your comment

Subject:
Message:
0/1000 characters