Working With Error Provider in VB.Net [Video Tutorial]

What is Error Provider?

Error provider is a control that alerts the user that something is wrong in his input. Or simply it just helps in validating data entered from user.
In this example, we will see how to display a warning icon when user enter some wrong or unacceptable input.

Working With Error Provider in VB.Net [Video Tutorial]

How to Use Error Provider in VB.Net

1. Simply drag a label & textbox control on your windows application form.

2. Change its Label text to ID or whatever you want.

3. Add a button & change its text to “Submit” on your windows form application.

4. Search for error provider in your toolbar & add it to your windows form application.

5. Double click Submit Button.

6. First we will check if the text in the textbox is numeric or not. If it not numeric then it will throw an exception else display confirmation message.

7. So the code to check if input is numeric is not is:
If Not IsNumeric(Me.Textbox1.Text) Then
Me.Errorprovider1.SetError (Me.Textbox1,”Enter Numeric Input”)
Return
Else
MsgBox(“Accepted”)
End If
8. Now, we will check for Null Values. Code to check Null Values is:
If Not IsNothing(Me.Textbox1.Text) Then
Me.Errorprovider1.SetError (Me.Textbox1,”Please enter some values”)
Return
Else
MsgBox(“Accepted”)
End If

Leave a Reply

Your email address will not be published. Required fields are marked *