在我的具体情况下,我需要 propertyPriceTextBox 中的值仅为数字和整数。还必须输入一个值,我可以只 Messagebox.Show() 一个警告,这就是我需要做的。
这就是我到目前为止所拥有的。
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.");
}