我是初學者這裏是我的代碼 我想從一個文本字段減去值到另一個,並顯示在第三個文本字段的結果,但問題是,我得到了錯誤輸入字符串格式沒有像 那樣格式正確,我該怎麼辦?從一個Textfield減去另一個有錯誤
我覺得我的代碼是正確的,但我不知道發生了什麼
private void txt_pay2_TextChanged(object sender, EventArgs e)
{
try
{
if (!string.IsNullOrEmpty(txt_pay2.Text))
{
txt_dues2.Text = (Convert.ToInt32(pay_dues.Text) - Convert.ToInt32(txt_pay2.Text)).ToString();
}
else if (String.IsNullOrEmpty(txt_pay2.Text))
{
MessageBox.Show("Enter A Amount Please !!");
}
}
catch (Exception Ex)
{
MessageBox.Show(Ex.Message);
}
}
你把數值在'pay_dues.Text'和'txt_pay2.Text'? –
顯示你在txt文件夾中的內容。 – swdev95
是的,我把數字值 –