title: Vaildate text boxes and combo boexs in vb.net
body: <p>Am trying to validate the data in the text-boxes and combo-boxes in my vb.net program that  is connected to an access database.</p>
  
  <p>I have used the following code below but get an error message;</p>
  
  <pre><code>Private Sub cmdadd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdadd.Click
  
    ShowAllStock.StockDataTableAdapter.Insert(Me.cboitemtype.Text, Me.TextBox2.Text, Me.cbocompany.Text, Me.TextBox3.Text, Me.TextBox4.Text)
    ShowAllStock.StockDataTableAdapter.Fill(ShowAllStock.Logins1DataSet.StockData)
  
    If TextBox2.Text = "" Then
      MsgBox("Please Fill In Your Name", MsgBoxStyle.Critical, "Please Fill In Your Name")
    ElseIf TextBox4.Text = "" Then
      MsgBox("Please Fill In the Total Cost Box", MsgBoxStyle.Critical, "Please Enter Cost")
    ElseIf cboitemtype.Text = "" Then
      MsgBox("Please Select Item Type", MsgBoxStyle.Critical, "Please Select Item Type")
    ElseIf cbocompany.Text = "" Then
      MsgBox("Please Select Company Delivered By", MsgBoxStyle.Critical, "Please Select Company Delivered By")
    ElseIf TextBox3.Text = "" Then
      MsgBox("Please Fill In Quantity", MsgBoxStyle.Critical, "Please Fill In Quantity")
    Else
      MsgBox("Records Added Successfully")
      cboitemtype.Text = ""
      TextBox2.Text = ""
      cbocompany.Text = ""
      TextBox3.Text = ""
      TextBox4.Text = ""
    End If
  End Sub
  </code></pre>