473,749 Members | 2,402 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Checking textbox is empty or not

1 New Member
hi

i am adding two numbers in C#.net & i want to check wheather first textbox is empty or not. if empty, then it must display "enter the first number" otherwise value is stored in first textbox1. Similarly for second textbox. and the sum of two numbers is stored third textbox.

thank you,
Sep 29 '06 #1
1 1975
anaphaxeon
30 New Member
private int Number1 = 0;
private int Number2 = 0;


protected internal void AddNumbers()
{
ValidateForm();
this.TextBox3.T ext = Convert.ToStrin g(Number1 + Number2);
}
protected internal void ValidateForm()
{
try
{
Number1 = Convert.ToInt32 (this.TextBox1. Text);
}
catch
{
MessageBox.Show ("Please enter a valid number 1!");
this.TextBox1.F ocus();
this.TextBox1.S electAll();
}
try
{
Number2 = Convert.ToInt32 (this.TextBox2. Text);
}
catch
{
MessageBox.Show ("Please enter a valid number 2!");
this.TextBox2.F ocus();
this.TextBox2.S electAll();
}
}
Oct 6 '06 #2

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

Similar topics

0
1514
by: Tetet B via .NET 247 | last post by:
I'm using VB.Net and trying to retrieve the data in the textboxcell of a datagrid after a successful display (used Databind).User can either display data or enter data in the textbox. I canalways get the textbox object using either the Controls orFindControl method but it's always returning an empty *.Textinstead of the value displayed on the screen. Below are snippetsof my code - anybody there who can help me PLEASE? =====*.vb <edit mode...
10
1383
by: Samir | last post by:
Say I have 4 forms, all four have different numbers of text boxes. is there a script that I can use to check to make sure everything on the form is not blank?
1
2009
by: Johann Blake | last post by:
I have a form with a single textbox control which is bound to a DataRelation in a typed dataset. The textbox displays the name of the product depending on the language selected from a combobox. When you select a different language, the textbox must show the name of the product in the selected language. This is done by setting the RowFilter property of the DefaultView on the table where the text comes from. If no text exists (that is, no...
2
2567
by: buran | last post by:
Dear ASP.NET Programmers, I have a question about a script I'm trying to code and invoke when a button (btnSave) is pressed on the page. This script should only run when a textbox (txtAD) on the page is left blank. I tried to use a code snippet with the "return confirm" function but without success. The code should check whether the textbox is empty or not, and if empty, it should ask the user to continue and then run the next code. How...
9
5659
by: D. Shane Fowlkes | last post by:
(ASP.NET 2 / VB) Question - How can I write a If statement to see if a control (textbox) actually exists on a page? Upon page_load, a certain control may or may not be visible on the page so I need to first check to see if it actually exists and then if it does, get the value from it. If I try to read it or check if its "visible" if it's not on the page then of course, it'll error. Thanks!
2
3167
by: Adam Honek | last post by:
I have a form. It has serveral text boxes for user data entry. I could of course write code to check if each is empty before proceeding to save this data to a file. Is there any global way to control if any of these text boxes is empty or are we really forced to do it on a one by one basis doing If....End is so many times?
1
31383
by: Brad Pears | last post by:
I am using vb.net 2005 and SQL server 2000. In my table I have a date field of type "smalldatetime". In my vb application, the user may or may not enter a date value into the appropriate text box. I then want to pass the value of this text box as a datetime variable to my stored procedure which inserts or updates the row. As I mentioned above, the textbox may be left blank - hence I would want to pass a null to the stored proc. How do I...
5
3628
by: bob | last post by:
Hi, i want to check whether the textbox of the detailsview is not left empty, in insert mode. I did this: Protected Sub DetailsView1_ItemInserting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DetailsViewInsertEventArgs) Handles DetailsView1.ItemInserting Dim h As String
4
2968
by: BillE | last post by:
I have found articles on line about using word interop for spell checking with visual studio applications. Most of the articles are several years old, though - VS2003, maybe 2005. I couldn't find anything for VS2008. Are there any new improvements in spell checking with VS2008? Thanks Bill
0
8996
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
9333
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8256
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6800
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6078
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4608
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4879
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3319
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2791
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.