Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8739935
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T11:02:35+00:00 2026-06-13T11:02:35+00:00

So I am making a windows form with a separate class for student details

  • 0

So I am making a windows form with a separate class for student details and international student. I need to validate that my Year mark for the student/international student is More than 0 and less than 100.

I would Also like to get the date of birth to show as dd/mm/yyyy but currently it shows as that plus the time.

I will include code below:

Date of birth first

student1.DateOfBirth = DateTime.Parse(txtDateofbirth.Text).Date;

if (string.IsNullOrEmpty(txtDateofbirth.Text))
{
    MessageBox.Show("Please enter a DoB");
}

Now for the Year Mark

try // Trying to do the thing in the curly braces
{
    student1.YearMark = Int32.Parse(txtYearMark.Text);
}
catch (Exception) // If it doesn't work skip the crash and print this
{
    MessageBox.Show("The Year mark must be a number and can't be empty");
} 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T11:02:35+00:00Added an answer on June 13, 2026 at 11:02 am

    I would recommend you to use a DateTimePicker control for entering dates and a NumericUpDown control to enter the YearMark, instead of using TextBox.

    The DateTimePicker control allows you to define the display format and restrict entry to a certain range. If I remember correctly the Value property is of type DateTime so you don’t have to parse a string.

    The NumericUpDown control allows you to define a range of allowed values. The Value property is of type Decimal, but you can safely cast that to an Int32. That’s a lot safer than parsing a String.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was making an RAII class that takes in a System.Windows.Form control, and sets
While making some final tests of a class-library that I'm writing for Windows Mobile
I'm making a windows form application that uses threads, the threads is running and
I'm making a small Windows Form application that contains a lot of grid views.
I'm making a Windows Form project that will search for files in the specified
I'm making a C# windows form application that needs to parse data from an
I'm making a Class Library and I'm using it inside a Windows Form Program.
I'm making a Windows Form Application with VS 2010. I've added a ProgressBar to
I made a .NET Windows form that allows users to view a particular document
I'm making a windows form. Here is my current code: I don't have any

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.