-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”)'等,会发生什么情况。 –