-1
由於某種原因,我無法包住我的頭爲什麼這不起作用......這是我的代碼,每次我嘗試一個具有NM或PT的不同帳戶時,它總是顯示0.11我似乎無法找出爲什麼....IF statement == not working
// Declare tax variables
string salesTax = customerLookup.Rows[0].Cells[4].Text;
double nmTax = .15;
double jackTax = .014;
double ptTax = .013;
double noTax = .11;
//If statement to pull correct tax price based on which tax bracket they are in
if (salesTax == "NM")
taxTextBox.Text = nmTax.ToString();
else if (salesTax == "JA")
taxTextBox.Text = jackTax.ToString();
else if (salesTax == "PT")
taxTextBox.Text = ptTax.ToString();
else
taxTextBox.Text = noTax.ToString();
如果我這樣做的代碼就說明NM或PT在文本框中,所以我在右邊的單元格...任何幫助是讚賞:
taxTextBox.Text = salesTax.ToString();
確保salesTax字符串中沒有尾隨空格,比較以及套管之前的修剪 – Isac
還要注意,這種情況在這裏會有所不同。 – maccettura
如果將其重寫爲'if(salesTax.Trim()==「NM」)'等,會發生什麼情況。 –