<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ru">
		<id>http://www.vbex.ru/index.php?action=history&amp;feed=atom&amp;title=VB.Net%2FGUI%2FTextBox_Validation</id>
		<title>VB.Net/GUI/TextBox Validation - История изменений</title>
		<link rel="self" type="application/atom+xml" href="http://www.vbex.ru/index.php?action=history&amp;feed=atom&amp;title=VB.Net%2FGUI%2FTextBox_Validation"/>
		<link rel="alternate" type="text/html" href="http://www.vbex.ru/index.php?title=VB.Net/GUI/TextBox_Validation&amp;action=history"/>
		<updated>2026-04-05T23:50:06Z</updated>
		<subtitle>История изменений этой страницы в вики</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>http://www.vbex.ru/index.php?title=VB.Net/GUI/TextBox_Validation&amp;diff=434&amp;oldid=prev</id>
		<title> в 16:40, 26 мая 2010</title>
		<link rel="alternate" type="text/html" href="http://www.vbex.ru/index.php?title=VB.Net/GUI/TextBox_Validation&amp;diff=434&amp;oldid=prev"/>
				<updated>2010-05-26T16:40:06Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr style=&quot;vertical-align: top;&quot; lang=&quot;ru&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Предыдущая&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Версия 16:40, 26 мая 2010&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; style=&quot;text-align: center;&quot; lang=&quot;ru&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(нет различий)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
			</entry>

	<entry>
		<id>http://www.vbex.ru/index.php?title=VB.Net/GUI/TextBox_Validation&amp;diff=435&amp;oldid=prev</id>
		<title>Admin: 1 версия</title>
		<link rel="alternate" type="text/html" href="http://www.vbex.ru/index.php?title=VB.Net/GUI/TextBox_Validation&amp;diff=435&amp;oldid=prev"/>
				<updated>2010-05-26T12:43:02Z</updated>
		
		<summary type="html">&lt;p&gt;1 версия&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Новая страница&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==TextBox Validating Event==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;vbnet&amp;quot;&amp;gt;&lt;br /&gt;
Imports System&lt;br /&gt;
Imports System.Collections&lt;br /&gt;
Imports System.Data&lt;br /&gt;
Imports System.IO&lt;br /&gt;
Imports System.Xml.Serialization&lt;br /&gt;
Imports System.Windows.Forms&lt;br /&gt;
Imports System.Drawing&lt;br /&gt;
Imports System.Drawing.Drawing2D&lt;br /&gt;
Imports System.Drawing.Text&lt;br /&gt;
Imports System.Drawing.Printing&lt;br /&gt;
&lt;br /&gt;
Public Class MainClass&lt;br /&gt;
    Shared Sub Main()&lt;br /&gt;
       Dim form1 As Form = New Form1()&lt;br /&gt;
       Application.Run(form1) &lt;br /&gt;
    End Sub&lt;br /&gt;
End Class&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Public Class Form1&lt;br /&gt;
    Inherits System.Windows.Forms.Form&lt;br /&gt;
#Region &amp;quot; Windows Form Designer generated code &amp;quot;&lt;br /&gt;
    Public Sub New()&lt;br /&gt;
        MyBase.New()&lt;br /&gt;
        &amp;quot;This call is required by the Windows Form Designer.&lt;br /&gt;
        InitializeComponent()&lt;br /&gt;
        &amp;quot;Add any initialization after the InitializeComponent() call&lt;br /&gt;
    End Sub&lt;br /&gt;
    &amp;quot;Form overrides dispose to clean up the component list.&lt;br /&gt;
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)&lt;br /&gt;
        If disposing Then&lt;br /&gt;
            If Not (components Is Nothing) Then&lt;br /&gt;
                components.Dispose()&lt;br /&gt;
            End If&lt;br /&gt;
        End If&lt;br /&gt;
        MyBase.Dispose(disposing)&lt;br /&gt;
    End Sub&lt;br /&gt;
    Friend WithEvents TextBox1 As System.Windows.Forms.TextBox&lt;br /&gt;
    Friend WithEvents Label1 As System.Windows.Forms.Label&lt;br /&gt;
    &amp;quot;Required by the Windows Form Designer&lt;br /&gt;
    Private components As System.ruponentModel.Container&lt;br /&gt;
    &amp;quot;NOTE: The following procedure is required by the Windows Form Designer&lt;br /&gt;
    &amp;quot;It can be modified using the Windows Form Designer.  &lt;br /&gt;
    &amp;quot;Do not modify it using the code editor.&lt;br /&gt;
    &amp;lt;System.Diagnostics.DebuggerStepThrough()&amp;gt; Private Sub InitializeComponent()&lt;br /&gt;
        Me.TextBox1 = New System.Windows.Forms.TextBox()&lt;br /&gt;
        Me.Label1 = New System.Windows.Forms.Label()&lt;br /&gt;
        Me.SuspendLayout()&lt;br /&gt;
        &amp;quot;&lt;br /&gt;
        &amp;quot;TextBox1&lt;br /&gt;
        &amp;quot;&lt;br /&gt;
        Me.TextBox1.Font = New System.Drawing.Font(&amp;quot;Microsoft Sans Serif&amp;quot;, 10.2!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))&lt;br /&gt;
        Me.TextBox1.Location = New System.Drawing.Point(48, 104)&lt;br /&gt;
        Me.TextBox1.Name = &amp;quot;TextBox1&amp;quot;&lt;br /&gt;
        Me.TextBox1.Size = New System.Drawing.Size(192, 27)&lt;br /&gt;
        Me.TextBox1.TabIndex = 1&lt;br /&gt;
        Me.TextBox1.Text = &amp;quot;&amp;quot;&lt;br /&gt;
        &amp;quot;&lt;br /&gt;
        &amp;quot;Label1&lt;br /&gt;
        &amp;quot;&lt;br /&gt;
        Me.Label1.Font = New System.Drawing.Font(&amp;quot;Microsoft Sans Serif&amp;quot;, 10.2!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))&lt;br /&gt;
        Me.Label1.Location = New System.Drawing.Point(24, 24)&lt;br /&gt;
        Me.Label1.Name = &amp;quot;Label1&amp;quot;&lt;br /&gt;
        Me.Label1.Size = New System.Drawing.Size(232, 48)&lt;br /&gt;
        Me.Label1.TabIndex = 2&lt;br /&gt;
        Me.Label1.Text = &amp;quot;Type somthing&amp;quot;&lt;br /&gt;
        &amp;quot;&lt;br /&gt;
        &amp;quot;Form1&lt;br /&gt;
        &amp;quot;&lt;br /&gt;
        Me.AutoScaleBaseSize = New System.Drawing.Size(6, 15)&lt;br /&gt;
        Me.ClientSize = New System.Drawing.Size(292, 268)&lt;br /&gt;
        Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.Label1, Me.TextBox1})&lt;br /&gt;
        Me.Name = &amp;quot;Form1&amp;quot;&lt;br /&gt;
        Me.Text = &amp;quot;Key Event Examples&amp;quot;&lt;br /&gt;
        Me.ResumeLayout(False)&lt;br /&gt;
    End Sub&lt;br /&gt;
#End Region&lt;br /&gt;
    Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged&lt;br /&gt;
    End Sub&lt;br /&gt;
    Public Sub TextBox1_Validating(ByVal sender As Object, _&lt;br /&gt;
      ByVal e As System.ruponentModel.CancelEventArgs) _&lt;br /&gt;
      Handles TextBox1.Validating&lt;br /&gt;
        &amp;quot; cancel the focus shift if the textbox is empty&lt;br /&gt;
         MessageBox.Show(&amp;quot;Validating&amp;quot;)&lt;br /&gt;
        If TextBox1.Text.Trim = Nothing Then e.Cancel = True&lt;br /&gt;
    End Sub&lt;br /&gt;
    &lt;br /&gt;
End Class&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==TextBox validation: validate in Button click event==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;vbnet&amp;quot;&amp;gt;&lt;br /&gt;
Imports System&lt;br /&gt;
Imports System.Drawing&lt;br /&gt;
Imports System.Windows.Forms&lt;br /&gt;
&lt;br /&gt;
Public Class MainClass&lt;br /&gt;
    &lt;br /&gt;
    Shared Sub Main()&lt;br /&gt;
        Dim form1 As Form = New Form1&lt;br /&gt;
        Application.Run(form1)&lt;br /&gt;
&lt;br /&gt;
    End Sub&lt;br /&gt;
End Class&lt;br /&gt;
Public Class Form1&lt;br /&gt;
    Inherits System.Windows.Forms.Form&lt;br /&gt;
#Region &amp;quot; Windows Form Designer generated code &amp;quot;&lt;br /&gt;
    Public Sub New()&lt;br /&gt;
        MyBase.New()&lt;br /&gt;
        &amp;quot;This call is required by the Windows Form Designer.&lt;br /&gt;
        InitializeComponent()&lt;br /&gt;
        &amp;quot;Add any initialization after the InitializeComponent() call&lt;br /&gt;
    End Sub&lt;br /&gt;
    &amp;quot;Form overrides dispose to clean up the component list.&lt;br /&gt;
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)&lt;br /&gt;
        If disposing Then&lt;br /&gt;
            If Not (components Is Nothing) Then&lt;br /&gt;
                components.Dispose()&lt;br /&gt;
            End If&lt;br /&gt;
        End If&lt;br /&gt;
        MyBase.Dispose(disposing)&lt;br /&gt;
    End Sub&lt;br /&gt;
    &amp;quot;Required by the Windows Form Designer&lt;br /&gt;
    Private components As System.ruponentModel.IContainer&lt;br /&gt;
    &amp;quot;NOTE: The following procedure is required by the Windows Form Designer&lt;br /&gt;
    &amp;quot;It can be modified using the Windows Form Designer.  &lt;br /&gt;
    &amp;quot;Do not modify it using the code editor.&lt;br /&gt;
    Friend WithEvents GroupBox1 As System.Windows.Forms.GroupBox&lt;br /&gt;
    Friend WithEvents Label2 As System.Windows.Forms.Label&lt;br /&gt;
    Friend WithEvents Label1 As System.Windows.Forms.Label&lt;br /&gt;
    Friend WithEvents txtFirstName As System.Windows.Forms.TextBox&lt;br /&gt;
    Friend WithEvents txtLastName As System.Windows.Forms.TextBox&lt;br /&gt;
    Friend WithEvents Button1 As System.Windows.Forms.Button&lt;br /&gt;
    Friend WithEvents errProvider As System.Windows.Forms.ErrorProvider&lt;br /&gt;
    Friend WithEvents txtEmail As System.Windows.Forms.TextBox&lt;br /&gt;
    Friend WithEvents Label3 As System.Windows.Forms.Label&lt;br /&gt;
    &amp;lt;System.Diagnostics.DebuggerStepThrough()&amp;gt; Private Sub InitializeComponent()&lt;br /&gt;
        Me.GroupBox1 = New System.Windows.Forms.GroupBox()&lt;br /&gt;
        Me.Label2 = New System.Windows.Forms.Label()&lt;br /&gt;
        Me.Label1 = New System.Windows.Forms.Label()&lt;br /&gt;
        Me.txtFirstName = New System.Windows.Forms.TextBox()&lt;br /&gt;
        Me.txtLastName = New System.Windows.Forms.TextBox()&lt;br /&gt;
        Me.Button1 = New System.Windows.Forms.Button()&lt;br /&gt;
        Me.errProvider = New System.Windows.Forms.ErrorProvider()&lt;br /&gt;
        Me.txtEmail = New System.Windows.Forms.TextBox()&lt;br /&gt;
        Me.Label3 = New System.Windows.Forms.Label()&lt;br /&gt;
        Me.GroupBox1.SuspendLayout()&lt;br /&gt;
        Me.SuspendLayout()&lt;br /&gt;
        &amp;quot;&lt;br /&gt;
        &amp;quot;GroupBox1&lt;br /&gt;
        &amp;quot;&lt;br /&gt;
        Me.GroupBox1.Controls.AddRange(New System.Windows.Forms.Control() {Me.Label3, Me.txtEmail, Me.Label2, Me.Label1, Me.txtFirstName, Me.txtLastName})&lt;br /&gt;
        Me.GroupBox1.Location = New System.Drawing.Point(8, 8)&lt;br /&gt;
        Me.GroupBox1.Name = &amp;quot;GroupBox1&amp;quot;&lt;br /&gt;
        Me.GroupBox1.Size = New System.Drawing.Size(368, 124)&lt;br /&gt;
        Me.GroupBox1.TabIndex = 11&lt;br /&gt;
        Me.GroupBox1.TabStop = False&lt;br /&gt;
        &amp;quot;&lt;br /&gt;
        &amp;quot;Label2&lt;br /&gt;
        &amp;quot;&lt;br /&gt;
        Me.Label2.Location = New System.Drawing.Point(16, 52)&lt;br /&gt;
        Me.Label2.Name = &amp;quot;Label2&amp;quot;&lt;br /&gt;
        Me.Label2.Size = New System.Drawing.Size(64, 16)&lt;br /&gt;
        Me.Label2.TabIndex = 8&lt;br /&gt;
        Me.Label2.Text = &amp;quot;Last Name:&amp;quot;&lt;br /&gt;
        &amp;quot;&lt;br /&gt;
        &amp;quot;Label1&lt;br /&gt;
        &amp;quot;&lt;br /&gt;
        Me.Label1.Location = New System.Drawing.Point(16, 28)&lt;br /&gt;
        Me.Label1.Name = &amp;quot;Label1&amp;quot;&lt;br /&gt;
        Me.Label1.Size = New System.Drawing.Size(64, 16)&lt;br /&gt;
        Me.Label1.TabIndex = 7&lt;br /&gt;
        Me.Label1.Text = &amp;quot;First Name:&amp;quot;&lt;br /&gt;
        &amp;quot;&lt;br /&gt;
        &amp;quot;txtFirstName&lt;br /&gt;
        &amp;quot;&lt;br /&gt;
        Me.txtFirstName.Location = New System.Drawing.Point(84, 24)&lt;br /&gt;
        Me.txtFirstName.Name = &amp;quot;txtFirstName&amp;quot;&lt;br /&gt;
        Me.txtFirstName.Size = New System.Drawing.Size(152, 21)&lt;br /&gt;
        Me.txtFirstName.TabIndex = 4&lt;br /&gt;
        Me.txtFirstName.Text = &amp;quot;&amp;quot;&lt;br /&gt;
        &amp;quot;&lt;br /&gt;
        &amp;quot;txtLastName&lt;br /&gt;
        &amp;quot;&lt;br /&gt;
        Me.txtLastName.Location = New System.Drawing.Point(84, 48)&lt;br /&gt;
        Me.txtLastName.Name = &amp;quot;txtLastName&amp;quot;&lt;br /&gt;
        Me.txtLastName.Size = New System.Drawing.Size(152, 21)&lt;br /&gt;
        Me.txtLastName.TabIndex = 5&lt;br /&gt;
        Me.txtLastName.Text = &amp;quot;&amp;quot;&lt;br /&gt;
        &amp;quot;&lt;br /&gt;
        &amp;quot;Button1&lt;br /&gt;
        &amp;quot;&lt;br /&gt;
        Me.Button1.Location = New System.Drawing.Point(152, 204)&lt;br /&gt;
        Me.Button1.Name = &amp;quot;Button1&amp;quot;&lt;br /&gt;
        Me.Button1.Size = New System.Drawing.Size(76, 24)&lt;br /&gt;
        Me.Button1.TabIndex = 10&lt;br /&gt;
        Me.Button1.Text = &amp;quot;OK&amp;quot;&lt;br /&gt;
        &amp;quot;&lt;br /&gt;
        &amp;quot;txtEmail&lt;br /&gt;
        &amp;quot;&lt;br /&gt;
        Me.txtEmail.Location = New System.Drawing.Point(84, 84)&lt;br /&gt;
        Me.txtEmail.Name = &amp;quot;txtEmail&amp;quot;&lt;br /&gt;
        Me.txtEmail.Size = New System.Drawing.Size(152, 21)&lt;br /&gt;
        Me.txtEmail.TabIndex = 9&lt;br /&gt;
        Me.txtEmail.Text = &amp;quot;&amp;quot;&lt;br /&gt;
        &amp;quot;&lt;br /&gt;
        &amp;quot;Label3&lt;br /&gt;
        &amp;quot;&lt;br /&gt;
        Me.Label3.Location = New System.Drawing.Point(16, 88)&lt;br /&gt;
        Me.Label3.Name = &amp;quot;Label3&amp;quot;&lt;br /&gt;
        Me.Label3.Size = New System.Drawing.Size(64, 16)&lt;br /&gt;
        Me.Label3.TabIndex = 10&lt;br /&gt;
        Me.Label3.Text = &amp;quot;Email:&amp;quot;&lt;br /&gt;
        &amp;quot;&lt;br /&gt;
        &amp;quot;ErrorProviderValidation&lt;br /&gt;
        &amp;quot;&lt;br /&gt;
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 14)&lt;br /&gt;
        Me.ClientSize = New System.Drawing.Size(388, 238)&lt;br /&gt;
        Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.GroupBox1, Me.Button1})&lt;br /&gt;
        Me.Font = New System.Drawing.Font(&amp;quot;Tahoma&amp;quot;, 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))&lt;br /&gt;
        Me.Name = &amp;quot;ErrorProviderValidation&amp;quot;&lt;br /&gt;
        Me.Text = &amp;quot;ErrorProvider Validation&amp;quot;&lt;br /&gt;
        Me.GroupBox1.ResumeLayout(False)&lt;br /&gt;
        Me.ResumeLayout(False)&lt;br /&gt;
    End Sub&lt;br /&gt;
#End Region&lt;br /&gt;
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click&lt;br /&gt;
        Dim InvalidInput As Boolean = False&lt;br /&gt;
        Dim ctrl As Control&lt;br /&gt;
        For Each ctrl In Me.GroupBox1.Controls&lt;br /&gt;
            If errProvider.GetError(ctrl) &amp;lt;&amp;gt; &amp;quot;&amp;quot; Then&lt;br /&gt;
                InvalidInput = True&lt;br /&gt;
                Exit For&lt;br /&gt;
            End If&lt;br /&gt;
        Next&lt;br /&gt;
        If InvalidInput = True Then&lt;br /&gt;
            MessageBox.Show(&amp;quot;You still have invalid input.&amp;quot;, &amp;quot;Invalid Input&amp;quot;, MessageBoxButtons.OK, MessageBoxIcon.Warning)&lt;br /&gt;
        Else&lt;br /&gt;
            Me.Close()&lt;br /&gt;
        End If&lt;br /&gt;
    End Sub&lt;br /&gt;
End Class&lt;br /&gt;
&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==TextBox validation: validate in Validating Event==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;vbnet&amp;quot;&amp;gt;&lt;br /&gt;
Imports System&lt;br /&gt;
Imports System.Drawing&lt;br /&gt;
Imports System.Windows.Forms&lt;br /&gt;
&lt;br /&gt;
Public Class MainClass&lt;br /&gt;
    &lt;br /&gt;
    Shared Sub Main()&lt;br /&gt;
        Dim form1 As Form = New Form1&lt;br /&gt;
        Application.Run(form1)&lt;br /&gt;
&lt;br /&gt;
    End Sub&lt;br /&gt;
End Class&lt;br /&gt;
Public Class Form1&lt;br /&gt;
    Inherits System.Windows.Forms.Form&lt;br /&gt;
#Region &amp;quot; Windows Form Designer generated code &amp;quot;&lt;br /&gt;
    Public Sub New()&lt;br /&gt;
        MyBase.New()&lt;br /&gt;
        &amp;quot;This call is required by the Windows Form Designer.&lt;br /&gt;
        InitializeComponent()&lt;br /&gt;
        &amp;quot;Add any initialization after the InitializeComponent() call&lt;br /&gt;
    End Sub&lt;br /&gt;
    &amp;quot;Form overrides dispose to clean up the component list.&lt;br /&gt;
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)&lt;br /&gt;
        If disposing Then&lt;br /&gt;
            If Not (components Is Nothing) Then&lt;br /&gt;
                components.Dispose()&lt;br /&gt;
            End If&lt;br /&gt;
        End If&lt;br /&gt;
        MyBase.Dispose(disposing)&lt;br /&gt;
    End Sub&lt;br /&gt;
    &amp;quot;Required by the Windows Form Designer&lt;br /&gt;
    Private components As System.ruponentModel.IContainer&lt;br /&gt;
    &amp;quot;NOTE: The following procedure is required by the Windows Form Designer&lt;br /&gt;
    &amp;quot;It can be modified using the Windows Form Designer.  &lt;br /&gt;
    &amp;quot;Do not modify it using the code editor.&lt;br /&gt;
    Friend WithEvents GroupBox1 As System.Windows.Forms.GroupBox&lt;br /&gt;
    Friend WithEvents Label2 As System.Windows.Forms.Label&lt;br /&gt;
    Friend WithEvents Label1 As System.Windows.Forms.Label&lt;br /&gt;
    Friend WithEvents txtFirstName As System.Windows.Forms.TextBox&lt;br /&gt;
    Friend WithEvents txtLastName As System.Windows.Forms.TextBox&lt;br /&gt;
    Friend WithEvents Button1 As System.Windows.Forms.Button&lt;br /&gt;
    Friend WithEvents errProvider As System.Windows.Forms.ErrorProvider&lt;br /&gt;
    Friend WithEvents txtEmail As System.Windows.Forms.TextBox&lt;br /&gt;
    Friend WithEvents Label3 As System.Windows.Forms.Label&lt;br /&gt;
    &amp;lt;System.Diagnostics.DebuggerStepThrough()&amp;gt; Private Sub InitializeComponent()&lt;br /&gt;
        Me.GroupBox1 = New System.Windows.Forms.GroupBox()&lt;br /&gt;
        Me.Label2 = New System.Windows.Forms.Label()&lt;br /&gt;
        Me.Label1 = New System.Windows.Forms.Label()&lt;br /&gt;
        Me.txtFirstName = New System.Windows.Forms.TextBox()&lt;br /&gt;
        Me.txtLastName = New System.Windows.Forms.TextBox()&lt;br /&gt;
        Me.Button1 = New System.Windows.Forms.Button()&lt;br /&gt;
        Me.errProvider = New System.Windows.Forms.ErrorProvider()&lt;br /&gt;
        Me.txtEmail = New System.Windows.Forms.TextBox()&lt;br /&gt;
        Me.Label3 = New System.Windows.Forms.Label()&lt;br /&gt;
        Me.GroupBox1.SuspendLayout()&lt;br /&gt;
        Me.SuspendLayout()&lt;br /&gt;
        &amp;quot;&lt;br /&gt;
        &amp;quot;GroupBox1&lt;br /&gt;
        &amp;quot;&lt;br /&gt;
        Me.GroupBox1.Controls.AddRange(New System.Windows.Forms.Control() {Me.Label3, Me.txtEmail, Me.Label2, Me.Label1, Me.txtFirstName, Me.txtLastName})&lt;br /&gt;
        Me.GroupBox1.Location = New System.Drawing.Point(8, 8)&lt;br /&gt;
        Me.GroupBox1.Name = &amp;quot;GroupBox1&amp;quot;&lt;br /&gt;
        Me.GroupBox1.Size = New System.Drawing.Size(368, 124)&lt;br /&gt;
        Me.GroupBox1.TabIndex = 11&lt;br /&gt;
        Me.GroupBox1.TabStop = False&lt;br /&gt;
        &amp;quot;&lt;br /&gt;
        &amp;quot;Label2&lt;br /&gt;
        &amp;quot;&lt;br /&gt;
        Me.Label2.Location = New System.Drawing.Point(16, 52)&lt;br /&gt;
        Me.Label2.Name = &amp;quot;Label2&amp;quot;&lt;br /&gt;
        Me.Label2.Size = New System.Drawing.Size(64, 16)&lt;br /&gt;
        Me.Label2.TabIndex = 8&lt;br /&gt;
        Me.Label2.Text = &amp;quot;Last Name:&amp;quot;&lt;br /&gt;
        &amp;quot;&lt;br /&gt;
        &amp;quot;Label1&lt;br /&gt;
        &amp;quot;&lt;br /&gt;
        Me.Label1.Location = New System.Drawing.Point(16, 28)&lt;br /&gt;
        Me.Label1.Name = &amp;quot;Label1&amp;quot;&lt;br /&gt;
        Me.Label1.Size = New System.Drawing.Size(64, 16)&lt;br /&gt;
        Me.Label1.TabIndex = 7&lt;br /&gt;
        Me.Label1.Text = &amp;quot;First Name:&amp;quot;&lt;br /&gt;
        &amp;quot;&lt;br /&gt;
        &amp;quot;txtFirstName&lt;br /&gt;
        &amp;quot;&lt;br /&gt;
        Me.txtFirstName.Location = New System.Drawing.Point(84, 24)&lt;br /&gt;
        Me.txtFirstName.Name = &amp;quot;txtFirstName&amp;quot;&lt;br /&gt;
        Me.txtFirstName.Size = New System.Drawing.Size(152, 21)&lt;br /&gt;
        Me.txtFirstName.TabIndex = 4&lt;br /&gt;
        Me.txtFirstName.Text = &amp;quot;&amp;quot;&lt;br /&gt;
        &amp;quot;&lt;br /&gt;
        &amp;quot;txtLastName&lt;br /&gt;
        &amp;quot;&lt;br /&gt;
        Me.txtLastName.Location = New System.Drawing.Point(84, 48)&lt;br /&gt;
        Me.txtLastName.Name = &amp;quot;txtLastName&amp;quot;&lt;br /&gt;
        Me.txtLastName.Size = New System.Drawing.Size(152, 21)&lt;br /&gt;
        Me.txtLastName.TabIndex = 5&lt;br /&gt;
        Me.txtLastName.Text = &amp;quot;&amp;quot;&lt;br /&gt;
        &amp;quot;&lt;br /&gt;
        &amp;quot;Button1&lt;br /&gt;
        &amp;quot;&lt;br /&gt;
        Me.Button1.Location = New System.Drawing.Point(152, 204)&lt;br /&gt;
        Me.Button1.Name = &amp;quot;Button1&amp;quot;&lt;br /&gt;
        Me.Button1.Size = New System.Drawing.Size(76, 24)&lt;br /&gt;
        Me.Button1.TabIndex = 10&lt;br /&gt;
        Me.Button1.Text = &amp;quot;OK&amp;quot;&lt;br /&gt;
        &amp;quot;&lt;br /&gt;
        &amp;quot;txtEmail&lt;br /&gt;
        &amp;quot;&lt;br /&gt;
        Me.txtEmail.Location = New System.Drawing.Point(84, 84)&lt;br /&gt;
        Me.txtEmail.Name = &amp;quot;txtEmail&amp;quot;&lt;br /&gt;
        Me.txtEmail.Size = New System.Drawing.Size(152, 21)&lt;br /&gt;
        Me.txtEmail.TabIndex = 9&lt;br /&gt;
        Me.txtEmail.Text = &amp;quot;&amp;quot;&lt;br /&gt;
        &amp;quot;&lt;br /&gt;
        &amp;quot;Label3&lt;br /&gt;
        &amp;quot;&lt;br /&gt;
        Me.Label3.Location = New System.Drawing.Point(16, 88)&lt;br /&gt;
        Me.Label3.Name = &amp;quot;Label3&amp;quot;&lt;br /&gt;
        Me.Label3.Size = New System.Drawing.Size(64, 16)&lt;br /&gt;
        Me.Label3.TabIndex = 10&lt;br /&gt;
        Me.Label3.Text = &amp;quot;Email:&amp;quot;&lt;br /&gt;
        &amp;quot;&lt;br /&gt;
        &amp;quot;ErrorProviderValidation&lt;br /&gt;
        &amp;quot;&lt;br /&gt;
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 14)&lt;br /&gt;
        Me.ClientSize = New System.Drawing.Size(388, 238)&lt;br /&gt;
        Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.GroupBox1, Me.Button1})&lt;br /&gt;
        Me.Font = New System.Drawing.Font(&amp;quot;Tahoma&amp;quot;, 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))&lt;br /&gt;
        Me.Name = &amp;quot;ErrorProviderValidation&amp;quot;&lt;br /&gt;
        Me.Text = &amp;quot;ErrorProvider Validation&amp;quot;&lt;br /&gt;
        Me.GroupBox1.ResumeLayout(False)&lt;br /&gt;
        Me.ResumeLayout(False)&lt;br /&gt;
    End Sub&lt;br /&gt;
#End Region&lt;br /&gt;
    Private Sub txtName_Validating(ByVal sender As Object, ByVal e As System.ruponentModel.CancelEventArgs) Handles txtFirstName.Validating, txtLastName.Validating&lt;br /&gt;
        If CType(sender, TextBox).Text = &amp;quot;&amp;quot; Then&lt;br /&gt;
            errProvider.SetError(sender, &amp;quot;You must enter a first and last name.&amp;quot;)&lt;br /&gt;
        Else&lt;br /&gt;
            errProvider.SetError(sender, &amp;quot;&amp;quot;)&lt;br /&gt;
        End If&lt;br /&gt;
    End Sub&lt;br /&gt;
End Class&lt;br /&gt;
&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Text Field Validation: five digits==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;vbnet&amp;quot;&amp;gt;&lt;br /&gt;
Imports System&lt;br /&gt;
Imports System.ruponentModel&lt;br /&gt;
Imports System.Windows.Forms&lt;br /&gt;
Imports System.Data&lt;br /&gt;
Imports System.Configuration&lt;br /&gt;
Imports System.Drawing&lt;br /&gt;
Imports System.Drawing.Drawing2D&lt;br /&gt;
Imports System.Drawing.Text&lt;br /&gt;
Imports System.Globalization&lt;br /&gt;
Imports System.Text&lt;br /&gt;
Imports System.Collections&lt;br /&gt;
Public Class MainClass&lt;br /&gt;
    Shared Sub Main()&lt;br /&gt;
        Dim myform As Form = New Form1()&lt;br /&gt;
        Application.Run(myform)&lt;br /&gt;
    End Sub&lt;br /&gt;
End Class&lt;br /&gt;
Public Class Form1&lt;br /&gt;
    Private Sub TextBox1_Validating(ByVal sender As Object, ByVal e As System.ruponentModel.CancelEventArgs) Handles TextBox1.Validating, TextBox2.Validating, TextBox3.Validating&lt;br /&gt;
        ValidateFiveDigits(DirectCast(sender, TextBox))&lt;br /&gt;
    End Sub&lt;br /&gt;
    Private Sub ValidateFiveDigits(ByVal text_box As TextBox)&lt;br /&gt;
        If (text_box.Text.Length &amp;lt;&amp;gt; 0) And _&lt;br /&gt;
        Not (text_box.Text Like &amp;quot;#####&amp;quot;) _&lt;br /&gt;
        Then&lt;br /&gt;
            &amp;quot; Invalid. Set an error.&lt;br /&gt;
            ErrorProvider1.SetError(text_box, _&lt;br /&gt;
            text_box.Name &amp;amp; &amp;quot; must contain exactly five digits&amp;quot;)&lt;br /&gt;
        Else&lt;br /&gt;
            &amp;quot; Valid. Clear the error.&lt;br /&gt;
            ErrorProvider1.SetError(text_box, &amp;quot;&amp;quot;)&lt;br /&gt;
        End If&lt;br /&gt;
    End Sub&lt;br /&gt;
&lt;br /&gt;
    Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing&lt;br /&gt;
        e.Cancel = True&lt;br /&gt;
        If IsInvalidField(TextBox1) Then &lt;br /&gt;
            Exit Sub&lt;br /&gt;
        End If&lt;br /&gt;
            &lt;br /&gt;
        If IsInvalidField(TextBox3) Then &lt;br /&gt;
            Exit Sub&lt;br /&gt;
        End If&lt;br /&gt;
        e.Cancel = False&lt;br /&gt;
    End Sub&lt;br /&gt;
    Private Function IsInvalidField(ByVal ctl As Control) As Boolean&lt;br /&gt;
        If ErrorProvider1.GetError(ctl).Length = 0 Then&lt;br /&gt;
            Return False&lt;br /&gt;
        Else&lt;br /&gt;
            MessageBox.Show(ErrorProvider1.GetError(ctl))&lt;br /&gt;
            ctl.Focus()&lt;br /&gt;
            Return True&lt;br /&gt;
        End If&lt;br /&gt;
    End Function&lt;br /&gt;
End Class&lt;br /&gt;
&amp;lt;Global.Microsoft.VisualBasic.rupilerServices.DesignerGenerated()&amp;gt; _&lt;br /&gt;
Partial Public Class Form1&lt;br /&gt;
    Inherits System.Windows.Forms.Form&lt;br /&gt;
    &amp;quot;Form overrides dispose to clean up the component list.&lt;br /&gt;
    &amp;lt;System.Diagnostics.DebuggerNonUserCode()&amp;gt; _&lt;br /&gt;
    Protected Overrides Sub Dispose(ByVal disposing As Boolean)&lt;br /&gt;
        If disposing AndAlso components IsNot Nothing Then&lt;br /&gt;
            components.Dispose()&lt;br /&gt;
        End If&lt;br /&gt;
        MyBase.Dispose(disposing)&lt;br /&gt;
    End Sub&lt;br /&gt;
    &amp;quot;Required by the Windows Form Designer&lt;br /&gt;
    Private components As System.ruponentModel.IContainer&lt;br /&gt;
    &amp;quot;NOTE: The following procedure is required by the Windows Form Designer&lt;br /&gt;
    &amp;quot;It can be modified using the Windows Form Designer.  &lt;br /&gt;
    &amp;quot;Do not modify it using the code editor.&lt;br /&gt;
    &amp;lt;System.Diagnostics.DebuggerStepThrough()&amp;gt; _&lt;br /&gt;
    Private Sub InitializeComponent()&lt;br /&gt;
        Me.ruponents = New System.ruponentModel.Container&lt;br /&gt;
        Me.Label1 = New System.Windows.Forms.Label&lt;br /&gt;
        Me.TextBox1 = New System.Windows.Forms.TextBox&lt;br /&gt;
        Me.TextBox2 = New System.Windows.Forms.TextBox&lt;br /&gt;
        Me.Label2 = New System.Windows.Forms.Label&lt;br /&gt;
        Me.TextBox3 = New System.Windows.Forms.TextBox&lt;br /&gt;
        Me.Label3 = New System.Windows.Forms.Label&lt;br /&gt;
        Me.ErrorProvider1 = New System.Windows.Forms.ErrorProvider(Me.ruponents)&lt;br /&gt;
        CType(Me.ErrorProvider1, System.ruponentModel.ISupportInitialize).BeginInit()&lt;br /&gt;
        Me.SuspendLayout()&lt;br /&gt;
        &amp;quot;&lt;br /&gt;
        &amp;quot;Label1&lt;br /&gt;
        &amp;quot;&lt;br /&gt;
        Me.Label1.AutoSize = True&lt;br /&gt;
        Me.Label1.Location = New System.Drawing.Point(8, 8)&lt;br /&gt;
        Me.Label1.Name = &amp;quot;Label1&amp;quot;&lt;br /&gt;
        Me.Label1.Size = New System.Drawing.Size(56, 13)&lt;br /&gt;
        Me.Label1.TabIndex = 0&lt;br /&gt;
        Me.Label1.Text = &amp;quot;Five Digits&amp;quot;&lt;br /&gt;
        &amp;quot;&lt;br /&gt;
        &amp;quot;TextBox1&lt;br /&gt;
        &amp;quot;&lt;br /&gt;
        Me.TextBox1.Location = New System.Drawing.Point(72, 8)&lt;br /&gt;
        Me.TextBox1.Name = &amp;quot;TextBox1&amp;quot;&lt;br /&gt;
        Me.TextBox1.Size = New System.Drawing.Size(80, 20)&lt;br /&gt;
        Me.TextBox1.TabIndex = 1&lt;br /&gt;
        &amp;quot;&lt;br /&gt;
        &amp;quot;TextBox2&lt;br /&gt;
        &amp;quot;&lt;br /&gt;
        Me.TextBox2.Location = New System.Drawing.Point(72, 32)&lt;br /&gt;
        Me.TextBox2.Name = &amp;quot;TextBox2&amp;quot;&lt;br /&gt;
        Me.TextBox2.Size = New System.Drawing.Size(80, 20)&lt;br /&gt;
        Me.TextBox2.TabIndex = 3&lt;br /&gt;
        &amp;quot;&lt;br /&gt;
        &amp;quot;Label2&lt;br /&gt;
        &amp;quot;&lt;br /&gt;
        Me.Label2.AutoSize = True&lt;br /&gt;
        Me.Label2.Location = New System.Drawing.Point(8, 32)&lt;br /&gt;
        Me.Label2.Name = &amp;quot;Label2&amp;quot;&lt;br /&gt;
        Me.Label2.Size = New System.Drawing.Size(56, 13)&lt;br /&gt;
        Me.Label2.TabIndex = 2&lt;br /&gt;
        Me.Label2.Text = &amp;quot;Five Digits&amp;quot;&lt;br /&gt;
        &amp;quot;&lt;br /&gt;
        &amp;quot;TextBox3&lt;br /&gt;
        &amp;quot;&lt;br /&gt;
        Me.TextBox3.Location = New System.Drawing.Point(72, 56)&lt;br /&gt;
        Me.TextBox3.Name = &amp;quot;TextBox3&amp;quot;&lt;br /&gt;
        Me.TextBox3.Size = New System.Drawing.Size(80, 20)&lt;br /&gt;
        Me.TextBox3.TabIndex = 5&lt;br /&gt;
        &amp;quot;&lt;br /&gt;
        &amp;quot;Label3&lt;br /&gt;
        &amp;quot;&lt;br /&gt;
        Me.Label3.AutoSize = True&lt;br /&gt;
        Me.Label3.Location = New System.Drawing.Point(8, 56)&lt;br /&gt;
        Me.Label3.Name = &amp;quot;Label3&amp;quot;&lt;br /&gt;
        Me.Label3.Size = New System.Drawing.Size(56, 13)&lt;br /&gt;
        Me.Label3.TabIndex = 4&lt;br /&gt;
        Me.Label3.Text = &amp;quot;Five Digits&amp;quot;&lt;br /&gt;
        &amp;quot;&lt;br /&gt;
        &amp;quot;ErrorProvider1&lt;br /&gt;
        &amp;quot;&lt;br /&gt;
        Me.ErrorProvider1.ContainerControl = Me&lt;br /&gt;
        &amp;quot;&lt;br /&gt;
        &amp;quot;Form1&lt;br /&gt;
        &amp;quot;&lt;br /&gt;
        Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)&lt;br /&gt;
        Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font&lt;br /&gt;
        Me.ClientSize = New System.Drawing.Size(210, 83)&lt;br /&gt;
        Me.Controls.Add(Me.TextBox3)&lt;br /&gt;
        Me.Controls.Add(Me.Label3)&lt;br /&gt;
        Me.Controls.Add(Me.TextBox2)&lt;br /&gt;
        Me.Controls.Add(Me.Label2)&lt;br /&gt;
        Me.Controls.Add(Me.TextBox1)&lt;br /&gt;
        Me.Controls.Add(Me.Label1)&lt;br /&gt;
        Me.Name = &amp;quot;Form1&amp;quot;&lt;br /&gt;
        Me.Text = &amp;quot;Deferred Validation&amp;quot;&lt;br /&gt;
        CType(Me.ErrorProvider1, System.ruponentModel.ISupportInitialize).EndInit()&lt;br /&gt;
        Me.ResumeLayout(False)&lt;br /&gt;
        Me.PerformLayout()&lt;br /&gt;
    End Sub&lt;br /&gt;
    Friend WithEvents Label1 As System.Windows.Forms.Label&lt;br /&gt;
    Friend WithEvents TextBox1 As System.Windows.Forms.TextBox&lt;br /&gt;
    Friend WithEvents TextBox2 As System.Windows.Forms.TextBox&lt;br /&gt;
    Friend WithEvents Label2 As System.Windows.Forms.Label&lt;br /&gt;
    Friend WithEvents TextBox3 As System.Windows.Forms.TextBox&lt;br /&gt;
    Friend WithEvents Label3 As System.Windows.Forms.Label&lt;br /&gt;
    Friend WithEvents ErrorProvider1 As System.Windows.Forms.ErrorProvider&lt;br /&gt;
End Class&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	</feed>