Quantcast
Channel: Active questions tagged email - Stack Overflow
Viewing all articles
Browse latest Browse all 30100

How to validate email address format?

$
0
0

I am creating a userform on which the user must enter certain information.

For example, I would like to make a condition or code to inform the user that he must enter a valid email address, and not only a msgbox because he can click OK and continue without modifying his email address.

I found this code but I found it hard to understand. What does it mean?

Function ValidEmail(eMail As String) As Boolean
    Dim MyRegExp As RegExp
    Dim myMatches As MatchCollection
    Set MyRegExp = New RegExp
    MyRegExp.Pattern = "^[a-z0-9_.-]+@[a-z0-9.-]{2,}\.[a-z]{2,4}$"
    MyRegExp.IgnoreCase = True
    MyRegExp.Global = False
    Set myMatches = MyRegExp.Execute(eMail)
    ValidEmail = (myMatches.Count = 1)
    Set myMatches = Nothing
    Set MyRegExp = Nothing
End Function

Viewing all articles
Browse latest Browse all 30100

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>