[Solved] How disable a button if there is no text in multiple textboxes in VB?


Change all of your “And” in your if statement to “Or”

Private Sub BtnStart_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnStart.Click
    If TxtBox1.Text = "" Or TxtBox2.Text = "" Or TxtBox3.Text = "" Or 
       TxtBox4.Text = "" Or TxtBox5.Text = "" Or TxtBox6.Text = "" Or
       TxtBox7.Text = "" Or TxtBox8.Text = "" Or TxtBox9.Text = "" Then
       TmrGame.Enabled = False
       MessageBox.Show("There Must Be A Total Of Nine Letters To Start The Game", "Not Enough Letters")
    Else
       TmrGame.Enabled = True
    End If
End Sub

By using And, you’re checking that all of the text boxes must be blank, then you’ll set your timer.Enabled to false. With Or, you’re saying if any of the text boxes are blank you’ll set the timer.Enabled to false.

solved How disable a button if there is no text in multiple textboxes in VB?