Good morning. As of this writing, the stock market appears to be on the verge of a complete collapse today. They have already halted selling and the market has not even opened due to the fall the futures market has already taken. Watching my retirement fly out the window as my broker is telling me to sit tight is not an easy thing for me to do. I am a person that has trouble sitting idly by and doing nothing. But that is my own character defect.
Anyway, the task before me is simple yet needed. I want to verify that the user has actually entered a valid email address. We are checking to make sure it is in a format that is an email address, not whether or not it is a legitimate email address. we accomplish by using regular expressions. To be honest, the regular expressions subject torments me. I don’t care for it but it works here nicely.
Make it a great day!
Function EmailAddressCheck(ByVal emailAddress As String) As Boolean
Dim pattern As String = "^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$"
Dim emailAddressMatch As Match = Regex.Match(emailAddress, pattern)
If emailAddressMatch.Success Then
EmailAddressCheck = True
EmailAddressCheck = False