2つのテキストボックスを比較して空かどうかを確認しようとしていますが、例外エラーが発生します。
入力文字列は、正しい形式ではありませんでした
コード:
private void btncalc_Click(object sender, EventArgs e)
{
try
{
int ina= int.Parse(txttea.Text);
int inb= int.Parse(txtcoffee.Text);
int inc = 0, ind = 0;
if (this.txttea.Text == "" && this.txtcoffee.Text == "") // this not working
{
MessageBox.Show("select a item");
txttea.Focus();
}
if (cbxwithoutsugar.Checked)
{
inc = (ina * 20);
}
else
{
inc = (ina * 8);
}
if (cbxcoldcoffee.Checked)
{
ind = (inb * 10);
}
else
{
ind = (inb * 5);
}
txtamount.Text = (Convert.ToInt32(inc) + Convert.ToInt32(ind)).ToString();
}
catch (Exception a)
{
MessageBox.Show(a.Message);
}
}