我得到這個部分代碼:爲什麼這個字符串比較不起作用?
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