CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: Coding help

  1. #1
    Join Date
    Mar 2011
    Posts
    4

    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?

  2. #2
    Join Date
    Oct 2005
    Location
    Seattle, WA U.S.A.
    Posts
    353

    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.

  3. #3
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: Coding help


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured