操作数类型与运算符不兼容

时间:2014-01-14 01:01:30

标签: axapta dynamics-ax-2009

我收到错误

  

操作数类型与运算符不兼容

尝试比较两个“真实”数据类型时标题中的

任何人都可以帮我解决错误吗?

public void clicked()
{
    real    localAnnualUsage    = itemSetup_DS.AnnualUsage();
    real    localSalesPrice     = itemSetup.StockPrice;
    real    localCost           = itemSetup.StockCost;
    real    localstockInventAvg = itemSetup.StockInventAvg;

    real    localTurnAndEarn;
    real    localAnnualGP;
    real    localAvgInvCost;
    ;

    localAvgInvCost = itemSetup.StockInventAvg;

    if (localStockInventAvg != itemSetup_StockInventAvg)
    {
        localAvgInvCost = itemSetup_StockInventAvg;
    }

    //...
}

错误发生在条件行上。

1 个答案:

答案 0 :(得分:5)

您的itemSetup_StockInventAvg变量很可能是真正的控件,而非真实。

尝试使用:

if (localStockInventAvg != itemSetup_StockInventAvg.realValue())

或更好(因为控件将结果存储在itemSetup.StockInventAvg中):

if (localStockInventAvg != itemSetup.StockInventAvg)

更新:这没有任何意义,因为之前localStockInventAvg被设置为itemSetup.StockInventAvg