VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Validates Email Address

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

Rate 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

Download this snippet    Add to My Saved Code

Validates Email Address Comments

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

Post your comment

Subject:
Message:
0/1000 characters