title: Validating Data in a Text Box C#
body: <p>I am making an application that Calculates a city's Population Increase or Decrease Percent. So you type a certain City and type in a certain State in their own text boxes and then you type in a beginning population in a 3rd textbox and an ending population in a 4th textbox, then hit calculate and it will display a increase or decrease based on the population data you entered.</p>
  
  <p>Now I validated the numbers for the population so that whenever a non numeric value is entered in the population text boxes, a message box will be displayed telling the user to enter in numeric data. </p>
  
  <p>I just cant figure out how to do the same with the city and state data. If somebody entered in a number in the city or state text box, how do I validate words? </p>
  
  <p>Whenever a number is entered in either the city or state text box, how can I display a message box saying "Invalid Format"?</p>
  
  <p>This is my Code</p>
  
  <pre><code>//Create a double for city
  double dblCity;
  
  //Create a Double for state
  double dblState;
  
  //Validate City
  if (double.TryParse(txtCity.Text, out dblCity))
  {
      //Validate State
      if (double.TryParse(txtState.Text, out dblState))
      {
  
      }
      else
      {
          //Display an error message for the textbox
          MessageBox.Show("Invalid input for State.");
  
          txtState.Focus();
          txtState.SelectAll();
      }
  }
  else
  {
      //Display an error message for the textbox
      MessageBox.Show("Invalid input for City.");
  
      txtCity.Focus();
      txtCity.SelectAll();
  }
  </code></pre>
  
  <p>It validates the City and State Text boxes to numeric values and anything else is invalid but I am trying to make it so when any numeric values are entered in the City or State Text Boxes it will be invalid. Only Words allowed in the City and State textboxes</p>