Division by zero

Hi everybody,

I have this on my report:
[IIF(<DBDind1."pkgs"> > 0,(<DBDind1."dkgs">/<DBDind1."pkgs">)*100, 0)]

Format of the Memo is number with ##,##0.## expression. Decimal separator-> .

I already tried:
[IIF(<DBDind1."pkgs"> > '0',(<DBDind1."dkgs">/<DBDind1."pkgs">)*100, '0')]
IIF(<DBDind1."pkgs"> > 0.1,(<DBDind1."dkgs">/<DBDind1."pkgs">)*100, 0)]

But nothing work.

At runtime error is Invalid floating point, where the Memo have zero value.

What I'm doing wronge ??

Any help will be very appreciated.

Comments

  • Anu de DeusAnu de Deus Hampshire, UK
    edited 1:00AM
    I guess it's geting confused with the excessive number of '>', specially in IIF(<DBDind1."pkgs"> > where you got 2 together.
    My suggestion is that you do it with an OnBeforePrintEvent, split the factors into separate variables, and calculate all from script.
    Something like
    <!--fonto:Courier New--><span style="font-family:Courier New"><!--/fonto-->OnMemoBeforePrint();
    a := <DBDind1."pkgs">
    b:= <DBDind1."dkgs">

    if a>0 then
    memo.text := (b/a)*100
    else
    ( ....)
    <!--fontc--></span><!--/fontc-->
    and so on

    I hope it gives you some ideas,
  • edited 1:00AM
    I guess it's geting confused with the excessive number of '>', specially in IIF(<DBDind1."pkgs"> > where you got 2 together.
    My suggestion is that you do it with an OnBeforePrintEvent, split the factors into separate variables, and calculate all from script.
    Something like
    <!--fonto:Courier New--><span style="font-family:Courier New"><!--/fonto-->OnMemoBeforePrint();
    a := <DBDind1."pkgs">
    b:= <DBDind1."dkgs">

    if a>0 then
    memo.text := (b/a)*100
    else
    ( ....)
    <!--fontc--></span><!--/fontc-->
    and so on

    I hope it gives you some ideas,
  • edited 1:00AM
    Hi, thanks by your fast reply,

    I'm afraid I have not scripting in my Basic version ? [img]style_emoticons/<#EMO_DIR#>/unsure.gif" style="vertical-align:middle" emoid=":unsure:" border="0" alt="unsure.gif" /> However, I'll try to code some like you told me. Thank you very much.[/img]
  • Anu de DeusAnu de Deus Hampshire, UK
    edited 1:00AM
    You should have scripting as everybody else.
    But by using it you will turn on the nag messages, I believe.
    Give it a quick try anyway

Leave a Comment