Click here to Skip to main content
15,894,405 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
if I put the code below in Private Sub Form_Load, it doesnt work but if i put the code in ΟνομαTextBox works and in ΚωδικοςTextBox works but only for this textbox i put the code in.

What I have tried:

Private Sub ΟνομαTextBox_TextChanged(sender As Object, e As EventArgs) Handles ΟνομαTextBox.TextChanged
       If ΟνομαTextBox.Text = "" Or ΚωδικοςTextBox.Text = "" Then
           Button2.Enabled = False
       Else
           Button2.Enabled = True
       End If
   End Sub
Posted
Updated 12-Feb-17 23:08pm
Comments
Richard MacCutchan 13-Feb-17 5:32am    
You should have a generic TextChanged method that is called when either TextBox contents are changed.

1 solution

You should handle the TextChanged-Ebvent from both Textboxes.
That could be look like :

VB
Private Sub TextBox_TextChanged(sender As Object, e As EventArgs) Handles ΟνομαTextBox.TextChanged , ΚωδικοςTextBox.TextChanged
        If ΟνομαTextBox.Text = "" Or ΚωδικοςTextBox.Text = "" Then
            Button2.Enabled = False
        Else
            Button2.Enabled = True
        End If
    End Sub
 
Share this answer
 
v3
Comments
Richard MacCutchan 13-Feb-17 5:31am    
They are Greek letters.
Member 12997620 15-Feb-17 7:04am    
if you mean that it doesnt work
Private Sub TextChangedEvent(sender As Object, e As EventArgs)
If TextBox1.Text = "" Or TextBox2.Text = "" Then
Button2.Enabled = False
Else
Button2.Enabled = True
End If
End Sub
Ralf Meier 15-Feb-17 7:47am    
No ... I mean that you should catch the TextChanged-Event from BOTH Textboxes to your Method.
Look for the differences between my code to yours ... (I try to mark my changes)
Member 12997620 15-Feb-17 12:50pm    
Thank you it works

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900