Is this the correct way to set value of textbox to zero when it's null? Is there any way I can improve the calculation that I am doing?
private void TB_PAID_CASH_TextChanged(object sender, EventArgs e)
{
try
{
if (!string.IsNullOrEmpty(TB_TOTAL_INV.Text) && !string.IsNullOrEmpty(TB_PAID_CASH.Text) && string.IsNullOrEmpty(TB_Discount.Text))
{
int Discount;
int.TryParse(TB_Discount.Text, out Discount);
TB_REMAINDER.Text = (Convert.ToInt32(TB_PAID_CASH.Text) - Convert.ToInt32(TB_TOTAL_INV.Text) - Discount).ToString();
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Exception", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
TextBoxrather than aNumericUpDowncontrol for this? \$\endgroup\$