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
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