473,399 Members | 3,038 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

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

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.  

2 1225
IronRazer
83 64KB
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
Sorry forgot to say thanks. Great help
Apr 11 '13 #3

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

Similar topics

0
by: Nigel Rivett | last post by:
This happened last week and it's happened again today. Last week it suddenly started working after a reboot of a server - we tried rebooting that server and it didn't help so it was probably a...
3
by: don | last post by:
I have a button on an ASP.net form, the button invites people to our event, so in the code behind I do some database calls and verify information, then invite them. My question is that, we would...
2
by: Just Me | last post by:
Private Sub TreeViewFolders_DoubleClick(ByVal se... If TreeViewFolders.MouseButtons <> MouseButtons.Right Then If, as above, I try to check which mouse button caused the DoubleClick I get...
14
by: Mike Collins | last post by:
In my page initialize, I am loading dynamic controls for a survey. On the survey, I have a stop button. If the user clicks the stop button, because of the page life cycle, the initialize and page...
2
by: geethapriya | last post by:
How can i output sound on button press in java? I've used Jframe for button creation! Plz help me!! All i need is a simple beep sound when the button is pressed!
2
by: IISPro | last post by:
I'm building a simple ASP.NET Windows application One the Windows Form there is a Button. If you click on it it calls a subroutine What I want to do is the Sub routine once it complete start...
5
by: Smokey Grindel | last post by:
I have a button on the form which has causes validation set to true... when I click on it not one of my validating events fires on the form... every single control with it just skips over it and...
0
by: sonia.sardana | last post by:
I have two buttons Play & Full Screen. If u click on Play Button,Movie starts..Movie Starts within 15-20 Seconds.....When u clik on Full Screen Button.,Media Player is Maximised. I want the if the...
23
by: shashi shekhar singh | last post by:
Dear sir, I have a word document file contains text and images, now i have saved it as a web page and wants to display it on browser , using , string str=directory.getfiles("");...
3
by: slenish | last post by:
Hi, Ok what I have is a form where I built a search feature that runs a query when you press a search button. It works great but the results pop up in another window and im trying to make it so...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.