|
-
March 20th, 2011, 07:14 PM
#1
Coding help
This is probably a basic question but I am very new to C# so bare with me. I am trying to make it so when a text box (labeled LastNameTextBox) is not filled in and a user clicks the Print button a message will pop up that says "Please enter a last name." I also have to do this with a first and last name and have already gotten this to work with a phone number in a Mased Text Box. This is my code thus far in this section:
string s = String.Empty;
Boolean pn = PhoneNumberMaskedTextBox.MaskFull;
Boolean ln = LastNameTextBox.
Boolean fn = FirstNameTextBox.
if (pn == false)
{
s = s + "Please enter a phone number.";
MessageBox.Show(s, "FUN Error Message", MessageBoxButtons.OK);
}
if (ln == false)
{
s = s + "Please enter a last name.";
MessageBox.Show(s, "FUN Error Message", MessageBoxButtons.OK);
}
if ((ln == false) && (fn == false))
{
s = s + "Please enter a full name.";
MessageBox.Show(s, "FUN Error Message", MessageBoxButtons.OK);
}
My problem is that I can't seem to figure out what comes after the period in LastNameTextBox. (same issue with FirstNameTextBox.) What do I need to put after those periods?
-
March 20th, 2011, 11:00 PM
#2
Re: Coding help
I dunno ... maybe sumthin' like
bool ln = !string.IsNullOrEmpty(LastNameTextBox.Text);
Actually, there's a wealth of information available to you via the VS Help section. Just click on the Help/view Help and enter what you're lookin' for, such as, say, Textbox class ....
http://msdn.microsoft.com/en-us/libr...s.textbox.aspx
or "String class", yielding
http://msdn.microsoft.com/en-us/libr...em.string.aspx
It's all at your fingertips, bro'
Old Fool
Last edited by ThermoSight; March 20th, 2011 at 11:03 PM.
-
March 20th, 2011, 11:15 PM
#3
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|