i have a form with 4 text boxes on them when the user selects add the information from the textboxes saves to my database im just wondering does anyone know how i would make an error message appear if one of the textboxes was blank and stop the new data being saved until all textboxes have data in them?
i did write the following peice of code but it did not work

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e_
As System.EventArgs) Handles Button1.Click
If TextBox1.Text = "" Then
ErrorProvider1.SetError(TextBox1, "Please enter data")
Else
ErrorProvider1.SetError(TextBox1, "")
End If
End Sub

Check the length of TextBox's Text,

IF TextBox1.Text.Trim().Length=0 Then
  ...
End If
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.