Advertisement
Sufyan

Email Validation

Aug 30th, 2012
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 0.80 KB | None | 0 0
  1. Imports System.Text.RegularExpressions
  2.  
  3. Public Class Form1
  4.     Dim newstr As String
  5.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  6.  
  7.  
  8.  
  9.  
  10.         If txtEmail_1.Text <> "" Then
  11.             Dim rex As Match = Regex.Match(Trim(txtEmail_1.Text), "^([0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*@([0-9a-zA-Z][-\w]*[0-9a-zA-Z]\.)+[a-zA-Z]{2,3})$", RegexOptions.IgnoreCase)
  12.             If rex.Success = False Then
  13.                 MessageBox.Show("Please Enter a valid Email-Address 1", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information)
  14.                 txtEmail_1.Focus()
  15.                 Exit Sub
  16.             Else
  17.                 MessageBox.Show("Right Email Address!", "Accepted!")
  18.             End If
  19.         End If
  20.  
  21.  
  22.  
  23.  
  24.     End Sub
  25.  
  26. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement