title: c# warn if  text box is empty or contains a non-whole number
body: <p>In my specific case, I need the value in propertyPriceTextBox to be numeric only, and a whole number. A value also has to be entered, and I can just Messagebox.Show() a warning and that's all I'd need to do.</p>
  
  <p>This is what I have so far.</p>
  
  <pre><code>        private void computeButton_Click(object sender, EventArgs e)
      {
          decimal propertyPrice;
  
          if ((decimal.TryParse(propertyPriceTextBox.Text, out propertyPrice)))
              decimal.Parse(propertyPriceTextBox.Text);
          {
  
              if (residentialRadioButton.Checked == true)
  
  
  
                  commisionLabel.Text = (residentialCom * propertyPrice).ToString("c");
  
  
  
              if (commercialRadioButton.Checked == true)
  
                  commisionLabel.Text = (commercialCom * propertyPrice).ToString("c");
  
              if (hillsRadioButton.Checked == true)
  
                  countySalesTaxTextBox.Text = ( hilssTax * propertyPrice).ToString("c");
  
              if (pascoRadioButton.Checked == true)
  
                  countySalesTaxTextBox.Text = (pascoTax * propertyPrice).ToString("c");
  
              if (polkRadioButton.Checked == true)
  
                  countySalesTaxTextBox.Text = (polkTax * propertyPrice).ToString("c");
  
              decimal result;
  
                  result = (countySalesTaxTextBox.Text + stateSalesTaxTextBox.Text + propertyPriceTextBox.Text + comissionTextBox.Text).ToString("c");
          }
  
          else (.)
  
              MessageBox.Show("Property Price must be a whole number.");
      }
  </code></pre>