Hi all once again, today i will be teaching u all how to validate the email entered into a text box or label to be in correct email format. We will be using Regex to make email validation.
{Note: Remember to rename the "Name" of the textbox1 to "email" or it won't work and please check all the names of the labels from the video tutorial or alter it according to your project.}
Codes:
'General Declarations
Imports System.Text.RegularExpressions
____________________________________________________________________
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim FoundMatch As Boolean
Try
FoundMatch = Regex.IsMatch(email.Text, "\A(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?)\Z", RegexOptions.IgnoreCase)
Catch ex As ArgumentException 'Syntax error in the regular expression
End Try
If Not FoundMatch Then
Label2.Text=("Not a Valid Email Address")
Else
Label2.Text("Valid Email Address")
End If
End Sub
End Class
_________________________________________________________________________
Here is the video tutorial:
Subscribe to:
Post Comments (Atom)
Blog Archive
-
▼
2010
(13)
-
▼
April
(6)
- Textbox - Select All (Ctrl+A) and Scroll Visual Ba...
- Run Program on Windows Startup Tutorial Visual Ba...
- Email Validation Entered Into Textbox Tutorial Vis...
- Visual Basic Send Email - Smtp Tutorial - {VB.net}
- How to make form move Borderless (No Title Bar) Vi...
- Listbox Tutorial - Add, Remove Item, Save, Reload ...
-
▼
April
(6)
Nice. It helps me a lot.
ReplyDelete