How would you make it so if you entered ANY character in a text box a process would be carried out, But if you didn't enter anything the process wouldn't be carried out.
Double click your TextBox control. You will be taken to it's Text Changed event handler. Write the code that you want to be executed when any character in the textbox is entered.
Code:
Private Sub TextBox1_TextChanged(Sender As Object, e As EventArgs)
MsgBox("You have entered some shit into TextBox")
End Sub
Originally Posted by Hassan
Double click your TextBox control. You will be taken to it's Text Changed event handler. Write the code that you want to be executed when any character in the textbox is entered.
Code:
Private Sub TextBox1_TextChanged(Sender As Object, e As EventArgs)
MsgBox("You have entered some shit into TextBox")
End Sub
Will that code really work? I have a feeling your trolling me with "You have entered some shit into the TextBox"
I have a feeling you want to check for an empty textbox.
Try this.
Code:
If Not TextBox1.Text = Nothing then
'Do your shit here
Else
'Fail your shit here
End If
Hopefully, you get the point.
~ZerO
Originally Posted by iZ3RO
I have a feeling you want to check for an empty textbox.
Try this.
Code:
If Not TextBox1.Text = Nothing then
'Do your shit here
Else
'Fail your shit here
End If
Hopefully, you get the point.
~ZerO
You're doing it wrong. Should be:
Code:
If Not String.IsEmpty(TextBox1.Text) then
'Do your shit here
Else
'Fail your shit here
End If
@Nitehawk772: I am obviously not trolling you. FFS -.-
Originally Posted by Hassan
You're doing it wrong. Should be:
Code:
If Not String.IsEmpty(TextBox1.Text) then
'Do your shit here
Else
'Fail your shit here
End If
@Nitehawk772: I am obviously not trolling you. FFS -.-
Either one works. I have not used String.* in anything I do yet, so * = Nothing was what I know.
I am fairly certain either snippet will get the job done for what he is using it for.
~ZerO
Originally Posted by iZ3RO
Either one works. I have not used String.* in anything I do yet, so * = Nothing was what I know.
I am fairly certain either snippet will get the job done for what he is using it for.
~ZerO
Yeah you are right. I thought you did "TextBox = Nothing" instead of "TextBox1.Text = Nothing". My bad. You're would work too, but using String.IsNullOrEmpty would be a better approach.
Originally Posted by Hassan
Yeah you are right. I thought you did "TextBox = Nothing" instead of "TextBox1.Text = Nothing". My bad. You're would work too, but using String.IsNullOrEmpty would be a better approach.
I'd go back and read that again. :3 I made sure I put *.text in there.
Although, I will take on using that IsNullOrEmpty code. It does seem
like cleaner code to me.