Error Provider Validation VB .NET Program



Description:         
 
Validate the textbox control whether it has data or not
 Imports System
Imports System.Windows.Forms
Imports System.Drawing

Public Class validation_keyevent
    Private Sub TextBox2_Validating(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles TextBox2.Validating
        If TextBox2.Text = "" Then
            Me.AutoScaleBaseSize = New System.Drawing.Size(5, 15)
            Me.Text = "Error Provider Validation"
            ErrorProvider1.SetError(sender, "You must Provide the First Name")
        Else
            ErrorProvider1.SetError(sender, "")
        End If

    End Sub
    Private Sub TextBox3_Validating(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles TextBox3.Validating
        If TextBox3.Text = "" Then
            Me.AutoScaleBaseSize = New System.Drawing.Size(5, 15)
            Me.Text = "Error Provider Validation"
            ErrorProvider2.SetError(sender, "You must Provide the Last Name")
        Else
            ErrorProvider2.SetError(sender, "")
        End If
    End Sub

    Private Sub TextBox4_Validating(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles TextBox4.Validating
        If TextBox4.Text = "" Then
            Me.AutoScaleBaseSize = New System.Drawing.Size(5, 15)
            Me.Text = "Error Provider Validation"
            ErrorProvider3.SetError(sender, "You must Provide Address")
        Else
            ErrorProvider3.SetError(sender, "")
        End If
    End Sub

  

    Private Sub TextBox6_Validating(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles TextBox6.Validating

        Select Case TextBox6.Text.Length
            Case 0
                ErrorProvider5.SetError(sender, _TextBox6.Name & " " & "must provide six digits pincode")
            Case 1
                ErrorProvider5.SetError(sender, _TextBox6.Name & " " & "must contain exactly six digits")
            Case 2
                ErrorProvider5.SetError(sender, _TextBox6.Name & " " & "must contain exactly six digits")
            Case 3
                ErrorProvider5.SetError(sender, _TextBox6.Name & " " & "must contain exactly six digits")
            Case 4
                ErrorProvider5.SetError(sender, _TextBox6.Name & " " & "must contain exactly six digits")
            Case 5
                ErrorProvider5.SetError(sender, _TextBox6.Name & " " & "must contain exactly six digits")
            Case Else
                ErrorProvider5.SetError(sender, "")
        End Select
      
    End Sub

    Private Sub TextBox5_Validating(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles TextBox5.Validating
        If TextBox5.Text = "" Then
            Me.AutoScaleBaseSize = New System.Drawing.Size(5, 15)
            Me.Text = "Error Provider Validation"
            ErrorProvider4.SetError(sender, "You must Provide City")
        Else
            ErrorProvider4.SetError(sender, "")
        End If

OUTPUT

Contact:
Mr. Roshan P. Helonde
Mobile: +91-7276355704
WhatsApp: +91-7276355704

Email: roshanphelonde@rediffmail.com
Share:

Total Pageviews

CONTACT US

Prof. Roshan P. Helonde
Mobile: +917276355704
WhatsApp: +917276355704
Email: roshanphelonde@rediffmail.com

Enter Project Title

Popular Projects

All Archive

Contact Form

Name

Email *

Message *