Text will not change

  • (2 Pages)
  • +
  • 1
  • 2

17 Replies - 2980 Views - Last Post: 24 September 2012 - 09:31 AM Rate Topic: -----

#16 jaArch  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 217
  • Joined: 23-March 10

Re: Text will not change

Posted 24 September 2012 - 08:39 AM

I have tried that and it still doesn't work...this is kinda confusing to me:

 DateTime birthDate;

        if (!DateTime.TryParse(txtBirth.Text, out birthDate))
        {
            int year = DateTime.Today.Year - Convert.ToDateTime(txtBirth.Text).Year;

            if (year < 18)
            {
                lblError.ForeColor = System.Drawing.Color.Red;
                lblError.Text = "You must be 18 years or older.";
            }
        }

Was This Post Helpful? 0
  • +
  • -

#17 rgfirefly24  Icon User is offline

  • D.I.C Lover
  • member icon


Reputation: 260
  • View blog
  • Posts: 1,419
  • Joined: 07-April 08

Re: Text will not change

Posted 24 September 2012 - 08:53 AM

Did you read the document I linked for DateTime.TryParse? It returns a Boolean true/false based on if it was able to do the conversion or not. So if you want to do things if it passed then remove the exclamation point from the if statement. Also the second parameter for TryParse is an output parameter to hold the converted date. I would advise that you read up on our suggestions so that you understand what is going on instead of just trying to copy and paste our code examples into your code.
Was This Post Helpful? 1
  • +
  • -

#18 jaArch  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 217
  • Joined: 23-March 10

Re: Text will not change

Posted 24 September 2012 - 09:31 AM

Sorry - I didn't see the link at first...my bad
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2