stu nicholls dot com | menu - Professional dropdown #3

click here


Performing Data Validation in Controls

Public Class Form3
Private Sub TextBox1_Validating(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles TextBox1.Validating
'Checking whether the entry is made in the text box
If TextBox1.Text.Length = 0 Then
' set the error for an entry to be made
ErrorProvider1.SetError(TextBox1, "Hello This box can not be blank please fill in")
Else
'Clear the error for a valid entry made
ErrorProvider1.SetError(TextBox1, "")
End If
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
TextBox1.Focus()
If TextBox1.Text.Length = 0 Then
MessageBox.Show("Text Box is Empty")
Else
MessageBox.Show("You entered " & TextBox1.Text)
End If
End Sub
End Class



Types of Validation<< Previous    Next>>Mouse Event


comments powered by Disqus
click here
click here
Footer1