Because you have this code in the Form_Load event you are only setting the initial state of the
TextBox2
You also need to respond to the user entering data into
TextBox1
You
could put this into the
Private Sub TextBox1_KeyDown
event, but note that it would run each time the user pressed a key.
My preference is to act on the contents of
TextBox1
only when we are sure that the User has finished whatever they are doing in that control - The
TextBox_Validated
event is handy for that...
Private Sub TextBox1_Validated(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.Validated
If Me.TextBox1.Text.Length > 0 Then
Me.TextBox2.Enabled = True
Else
Me.TextBox2.Enabled = False
End If
End Sub