Noppadet
Noppadet

Reputation: 804

Operand Types Are Not Compatible With The Operator

I am receiving the error

Operand Types Are Not Compatible With The Operator

in the title when trying to compare two "real" datatypes.

Can anyone help me out with what is wrong?

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;
    }

    //...
}

The error happens with on the line of the conditional.

Upvotes: 1

Views: 2314

Answers (1)

Jan B. Kjeldsen
Jan B. Kjeldsen

Reputation: 18051

Most likely your itemSetup_StockInventAvg variable is a real control, not a real.

Try using:

if (localStockInventAvg != itemSetup_StockInventAvg.realValue())

or better (because the control stores the result in itemSetup.StockInventAvg):

if (localStockInventAvg != itemSetup.StockInventAvg)

Update: This makes no sense, since localStockInventAvg was set to itemSetup.StockInventAvg the line before.

Upvotes: 5

Related Questions