by Chris Morton (5 Submissions)
Category: Miscellaneous
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Fri 30th September 2005
Date Added: Mon 8th February 2021
Rating: (1 Votes)
Validates Email Address
Dim i As Integer
Dim atplace As Integer
Dim atcount As Integer
Dim atcountboo As Boolean
Dim dotcount As Integer
For i = 1 To Len(Email)
If Mid(Email, i, 1) = "@" Then 'Checks where the location of the @ symbol is and if there is more than 1
atcount = atcount + 1
atplace = i
End If
If Mid(Email, i, 1) = "." Then
dotcount = dotcount + 1
End If
If Mid(Email, i, 1) = "!" Or Mid(Email, i, 1) = "#" Then 'checks for illegal characters
Return False
Exit Function
End If
Next
If atcount <> 1 Then 'checks if there are invalid or no @ symbols
atcountboo = False
Else
atcountboo = True
End If
If Mid(Email, 1, 1) = "@" Then 'checks if the first charater is @
Return False
End If
If Mid(Email, atplace + 1, 1) = "." Then 'checks if the character after @ is a .
Return False
End If
If dotcount >= 1 And atcountboo = True Then 'checks if there is at least 1 . and an @ exists in the right place
Return True
Else
Return False
End If
End Function