Quick Question.

Posts 1–8 of 8 · Page 1 of 1
Quick Question.
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
Quote Originally Posted by Hassan View Post
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
Quote Originally Posted by iZ3RO View Post
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 -.-
Quote Originally Posted by Hassan View Post


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
Quote Originally Posted by iZ3RO View Post
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.
Quote Originally Posted by Hassan View Post
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.

~ZerO
Posts 1–8 of 8 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Need help?