我得到这个部分代码:为什么这个字符串比较不起作用?
var
MYOBCardId, WSCustCode, ExCode,
Destination, IncomeStream, MyobSalesAc: String;
IncomeStream := VarToStr(Trim(SheetData.Cells[7, StrRow]));
MyobSalesAc := '';
if IncomeStream = '840 DRUG-temp controlled' then
MyobSalesAc := '42400';
if AnsiCompareStr(IncomeStream,'900 Industrial') = 0 then
MyobSalesAc := '41200';
if IncomeStream = '950 Live Animals' then
MyobSalesAc := '41800';
的事情是,如果再声明似乎并没有工作。如果IncomeStream的值是'900 Industrial'(通过调试器检查),MYOBSalesAc将是''而不是'41200'。 比较完全不起作用。它对所有的值都是一样的。使用AnsiComparestr不会给出正确的结果。
任何指针?
问候 拉希德
'IncomeStream'是不是你说的样子。已知'AnsiCompareStr'工作正常。 – 2012-02-29 14:50:27
我试着使用IncomeStream ='900 Industrial',其中IncomeStream ='900 Industrial'。如果它是真的,结果是错误的。 – mra 2012-02-29 14:54:35
'='运算符也可以正常工作。 – 2012-02-29 14:55:21