KenQui
Member
- Joined
- May 11, 2022
- Messages
- 12
- Programming Experience
- Beginner
I have three textbox, one datetimepicker, one button for save and one errorprovider.
The problem is every time I input a data in textbox and I forgot to select the date it give an error in datetimepicker then when I select a date because I forgot it then save it the error provider still in their.
the thing I want is after I select a date because it give an error then save it. The error will be gone
Pls help me I cant fine the correct code and because I'm still beginner.
Below is the code that I'm using.
The problem is every time I input a data in textbox and I forgot to select the date it give an error in datetimepicker then when I select a date because I forgot it then save it the error provider still in their.
the thing I want is after I select a date because it give an error then save it. The error will be gone
Pls help me I cant fine the correct code and because I'm still beginner.
Below is the code that I'm using.
VB.NET:
Private Sub cmdSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdSave.Click
If DateTimePicker1.Value.Date < Date.Today Then
ErrorProvider1.SetError(DateTimePicker1, "DATE SELECTED IS LESS THAN TODAYS DATE")
Else
ErrorProvider1.SetError(DateTimePicker1, "PLEASE SELECT DATE TODAY")
End If
AddBook()
End Sub