I'm doing a program for a class, and when I run it and type something in the txtSSN control that's not valid, it freezes up and crashes. I can't figure it out because I have another very similar project that works just fine.

```
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Text.RegularExpressions;

namespace VitalStatistics
{
    public partial class frmVitalStatistics : Form
    {
        #region Declarations

        const String AppTitle = "Vital Statistics";
        const float hoursOffset = 24.999F;

        Regex ssnRegex;

        #endregion

        #region Constructors
        public frmVitalStatistics()
        {
            InitializeComponent();
        }
    #endregion

        #region Event Handlers

       private void frmVitalStatistics_Load(object sender, EventArgs e)
        {

         // Initialize SSN input control
            RegexOptions options = RegexOptions.IgnorePatternWhitespace;
            string pattern = @"\A\d{3}-\d{3}-\d{4}\Z";
            ssnRegex = new Regex(pattern, options);

         // Init. Gender controls
            optGender = Gender.Unassigned;

            rbFemale.Tag = Gender.Male;
            rbMale.Tag = Gender.Female;

         // Init dtpBirth controls
            dtpBirth.MinDate = DateTime.Today;
            dtpBirth.MaxDate = DateTime.Today.AddHours(hoursOffset);
            dtpBirth.Value = DateTime.Today;

        }

       private void btnSubmit_Click(object sender, EventArgs e)
        {

            string name = String.Empty;
            string ssn = String.Empty;
            int length = 0;
            int weight = 0;

            DateTime birthDate = DateTime.MinValue;
            Gender gender = Gender.Unassigned;

           //Gather inputs

           if (GetName(ref name) &&
               GetSSN(ref ssn) &&
               GetLength(ref length) &&
               GetWeight(ref weight) &&
               GetGender(ref gender) &&
               GetBirthDate(ref birthDate))
           {
               //submit & close
               string format = 
                   "Thank you for submitting your contact information. \n\n" +
                   "Name: {0}\n" +
                   "SSN: {1}\n" +
                   "Length: {2}\n" +
                   "Weight: {3}\n" +
                   "Gender: {4}\n" +
                   "Birth Date & Time: {5:D}\n";

               string msg = String.Format(format, name, ssn, length, weight, gender, birthDate);
               MessageBox.Show(msg,AppTitle);
               Close();
           }
       }

       private Gender optGender;
       private void Gender_CheckedChanged(object sender, EventArgs e)
       {
           RadioButton rb = (RadioButton)sender;
           optGender = (rb.Checked ? (Gender)rb.Tag : Gender.Unassigned);
       }

        #endregion

        #region Implementation

        bool GetName(ref string name)
       {
           if (String.IsNullOrWhiteSpace(txtName.Text))
           {
               txtName.SelectAll();
               txtName.Focus();
               ShowError("Please enter your name.\n Names cannot consist of whitespace.");

               return false;
           }

           name = txtName.Text.Trim();

           return true;
       }

        bool GetSSN(ref string ssn)
       {
           txtSSN.Text = txtSSN.Text.Trim();

           Match match = ssnRegex.Match(txtSSN.Text);

           if (!match.Success)
           {
               txtSSN.SelectAll();
               txtSSN.Focus();
               ShowError("Unrecognized format for SSN. Please enter in the following format: 000-000-0000.");
               return false;

           }

           ssn = txtSSN.Text;
           return true;
       }

        bool GetLength(ref int length)
       {
           int value;
           try
           {
               if (String.IsNullOrWhiteSpace(txtLength.Text))
                   throw new ArgumentException("Field cannot be empty or contain spaces.");

               value = int.Parse(txtLength.Text);

           }
           catch (Exception ex)
           {
               // Select text and set focus
               txtLength.SelectAll();
               txtLength.Focus();

               // Set up error Message
               string msg = String.Format("{0}", ex);

               ShowError(ex.Message);
               return false;
           }

           length = value;
           return true;
       }

        bool GetWeight(ref int weight)
        {
            int value;
            try
            {
                if (String.IsNullOrWhiteSpace(txtWeight.Text))
                    throw new ArgumentException("Field cannot be empty or contain spaces.");

                value = int.Parse(txtLength.Text);

            }
            catch (Exception ex)
            {
                // Select text and set focus
                txtWeight.SelectAll();
                txtWeight.Focus();

                // Set up error Message
                string msg = String.Format("{0}", ex);

                ShowError(ex.Message);
                return false;
            }

            weight = value;
            return true;
        }

        bool GetGender(ref Gender gender)
        {
            if (optGender == Gender.Unassigned)
            {
                ShowError("Select a Gender.");
                return false;
            }
            gender = optGender;
            return true;
        }

        bool GetBirthDate(ref DateTime birthDate)
        {
           birthDate = dtpBirth.Value;
           return true;
        }

        void ShowError(string msg)
        {
           MessageBox.Show(msg, AppTitle, MessageBoxButtons.OK, MessageBoxIcon.None);
        }

         #endregion

    }

}

```