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:40AM
    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:40AM
    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:40AM
    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:40AM
    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

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.