By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,524 Members | 1,475 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,524 IT Pros & Developers. It's quick & easy.

Stuck with IF statement to determine whether a button can be pressed or not

P: 2
Hi i am making a project and need some help!
I have a button that can be pressed then a progress bar loads up,
But i want to make it so that if there is no text in textbox1,2 or 3 then a window pops up to say that the details must be entered to proceed.
And if it is all in the textboxes, then the button can be pressed.

Thanks
Apr 9 '13 #1

✓ answered by IronRazer

Hello,
You can do this a few ways but, the easiest would be to just check if the textboxes have something in them when the button is pressed. This example will check if any of the three textboxes are left empty.
Expand|Select|Wrap|Line Numbers
  1.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  2.         If TextBox1.Text = "" Or TextBox2.Text = "" Or TextBox3.Text = "" Then
  3.             MessageBox.Show("You Must Enter Enter Info")
  4.         Else
  5.             'Start your timer or whatever here
  6.         End If
  7.     End Sub
  8.  

Share this Question
Share on Google+
2 Replies


IronRazer
P: 83
Hello,
You can do this a few ways but, the easiest would be to just check if the textboxes have something in them when the button is pressed. This example will check if any of the three textboxes are left empty.
Expand|Select|Wrap|Line Numbers
  1.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  2.         If TextBox1.Text = "" Or TextBox2.Text = "" Or TextBox3.Text = "" Then
  3.             MessageBox.Show("You Must Enter Enter Info")
  4.         Else
  5.             'Start your timer or whatever here
  6.         End If
  7.     End Sub
  8.  
Apr 9 '13 #2

P: 2
Sorry forgot to say thanks. Great help
Apr 11 '13 #3

Post your reply

Sign in to post your reply or Sign up for a free account.