Hi, im trying to disable a button until anything has been entered into two text boxes simultaneously.

So far i have tried:

If String.IsNullOrEmpty(TextBox1.Text & TextBox2.Text) Then
        Button1.Enabled = False
        Else
        Button1.Enabled = True
        End If

However it doesnt work simultaneously, the button will become enabled if i enter anything into either textbox, i cant have any of them left blank.

In your code TextBox1.Text & TextBox2.Text concatenates two strings. The resulting string will never be null or empty if either one of the textboxes is not null or not empty.

If String.IsNullOrEmpty(TextBox1.Text) OrElse String.IsNullOrEmpty(TextBox2.Text) Then
      Button1.Enabled = False
    Else
      Button1.Enabled = True
    End If

You have to check those textboxes separately.

In your code TextBox1.Text & TextBox2.Text concatenates two strings. The resulting string will never be null or empty if either one of the textboxes is not null or not empty.

If String.IsNullOrEmpty(TextBox1.Text) OrElse String.IsNullOrEmpty(TextBox2.Text) Then
      Button1.Enabled = False
    Else
      Button1.Enabled = True
    End If

You have to check those textboxes separately.

If I'm right, 2 criteria is to be fulfilled.I think it could be modified by changing a little something

If String.IsNullOrEmpty(TextBox1.Text) AndAlso String.IsNullOrEmpty(TextBox2.Text) Then
      Button1.Enabled = False
Else
      Button1.Enabled = True
End If

the orelse changed to AndAlso

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.