Visual Basic Code Snippet - Validate Email Address

Visual Basic Code Snippet - Validate Email Address

Visual Basic Code Snippet - Validate Email Address

(VB) Visual Basic code snippet to validate given email address. IsValidEmail function validate email address. Function return TRUE if valid email address found, if not function will return FALSE.

Bookmark:

Visual Basic Code Snippet - Validate Email Address

This .Net Visual Basic (VB) code snippet validate given email address. This function uses regular expression to match string pattern to validate email address.

Public Function IsValidEmail(ByVal Email As String) As Boolean
    Dim strRegex As String = "^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$"
    Dim _Regex As New System.Text.RegularExpressions.Regex(strRegex)
    Return _Regex.IsMatch(Email)
End Function


Visual Basic (VB) Keywords Used:

  • Regex
  • IsMatch

Code Snippet Information:

  • Applies To: .Net, VB, Visual Basic, Email Validation, Regular Expression
  • Programming Language : Visual Basic (VB)

External Resources:

Leave a comment