Check an Email Address for Validity (VB.NET and VB6)

Category:
C#, VB.NET, ASP.NET
Type:
Snippets
Difficulty:
Beginning
Author:
Chad M. Kovac

Version Compatibility: Visual Basic 6, Visual Basic 5, Visual Basic.NET

More information:
This function, which works in VB5, VB6, and VB.NET will allow you to call CheckEmail("some@emailaddress.com") to see if:
  • It doesn't contain invalid characters.
  • Doesn't have more than one @.
  • Has some text prior to the @.
  • Has some text after the @.
  • Has text between the @ and the "."
  • Has text after the last "."

Instructions: Copy the declarations and code below and paste directly into your VB project.

Declarations:

Code: