problem with the if statement

[IIf(([A]==0.00),0,(-[C])/[A]*100)]

this is the text of a field...
what i wan to do is when A is 0 then the filed will show 0, else the calculation will start...
but the problem is when i start the report this field will occur an error that saying the value was too large or too smale for a decimal,
and one more problem is when the [A] is 0 this problem happen too.(the field should show 0 and no calculation)
anyone can help me or give any idea?

Comments

  • edited 1:39AM
    Hello,

    Do not use IIf function in a calculation like this. The function evaluates both parameters, then returns one of them. Use ? operator instead:
    [[A]==0.00 ? 0 : (-[C])/[A]*100]
  • edited 1:39AM
    AlexTZ wrote: »
    Hello,

    Do not use IIf function in a calculation like this. The function evaluates both parameters, then returns one of them. Use ? operator instead:
    [[A]==0.00 ? 0 : (-[C])/[A]*100]

    Thank you for your reply...Unfortunately it's not fully work as error CS0172 will occur...
    will appreciate your helpful reply...
  • edited 1:39AM
    Error CS0172 : Type of conditional expression cannot be determined because 'int' and 'FastRepot.Variant' implicitly convert to one another
  • edited 1:39AM
    You need to cast it to double:

    [[A]==0.00 ? 0 : (double)((-[C])/[A]*100)]

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.