TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
ta mu
NA
201
81.8k
if else statements
Aug 16 2012 9:18 AM
Dear
In this code on if else statements when press button if ptname or agee is empty
show mesgbox it works fine when any one of them is empty mesgbox apears but
it also save empty values mean other part of code also run.
but i want till any one of them empty control remain on them. rest of code no run
how i can do this.
private void button1_Click(object sender, EventArgs e)
{
if (ptname.Text == "")
{ MessageBox.Show("please enter a name"); }
else if (agee.Text == "")
{
MessageBox.Show("please enter age");
}
int counter = int.Parse(lb26.Text);
counter++;
lb26.Text = counter.ToString();
StreamWriter noo = new StreamWriter("d:\\Hospital\\hospital records.text", true);
string nooo = lb26.Text + " ";
noo.Write(nooo);
noo.Close();
StreamWriter pname = new StreamWriter("d:\\Hospital\\hospital records.text", true);
string paaname = ptname.Text + " " + " " + " " + " ";
pname.Write(paaname);
pname.Close();
StreamWriter age = new StreamWriter("d:\\Hospital\\hospital records.text", true);
string aage = agee.Text + " " + " " + " " + " ";
age.Write(aage);
age.Close();
StreamWriter sex = new StreamWriter("d:\\Hospital\\hospital records.text", true);
string se = comboBox1.SelectedItem + " " + " " + " " + " ";
sex.Write(se);
sex.Close();
Reply
Answers (
3
)
Convert Datetime? property value to string format
Excel Document