on the fastrepor 3.20 divide process

edited 5:16PM in FastReport 3.0
Hi All,

i want divide process on the fastreport 3,20. I wrote code as follows.Iam getting error message when I run the code."incompatible type:'Integer';Extended'"

How can i run this code ?

Regards.

procedure Memo23OnBeforePrint(Sender: TfrxComponent);
var
a,b:integer;
begin
  b:=StrToInt(memo10.value)/2;
memo23.text:=IntToStr(b)
end;

Comments

  • KelloucheKellouche Algeria
    edited May 2011
    hi

    just changed integer by extended
    procedure Memo23OnBeforePrint(Sender: TfrxComponent);
    var
      b:iextended;
    begin
      b:=memo10.value/2;
      memo23.text:=FloattoStr(b)
    end;
    
  • gordkgordk St.Catherines On. Canada.
    edited 5:16PM
    you have declared variable b as the wrong type it should be extended,
    since dividing the value can result in a non integer value.
    then you will also need to modify this line if you only want an iteger result
    memo23.text:=IntToStr(b)
    to
    memo23.text:=IntToStr(int(b))
  • edited 5:16PM
    Try
    procedure Memo23OnBeforePrint(Sender: TfrxComponent);
    var
       a,b:integer;
    begin
       b :=  Int( StrToInt(memo10.value) / 2);
       memo23.text := IntToStr( b )
    end;
    

    Mick
  • edited 5:16PM
    Thank you very much for you help, all people [img]style_emoticons/<#EMO_DIR#>/rolleyes.gif" style="vertical-align:middle" emoid=":rolleyes:" border="0" alt="rolleyes.gif" /> Regards.[/img]
  • edited May 2011
    Dear All,

    Could you please help another a issues. I am not getting decimal result on the calculation process when i do divide.

    For example My result: 17 porocess :17/3=5,66

    on the Above process was 17/3=5 I dont want this result. I want result 5,66.

    Could you please help to me this issues...

    Kind regards.
  • edited 5:16PM
    You didn't write the whole instruction. Give the example. Maybe you assign the result to an INTEGER variable.
    Test

    ShowMessage( 17/3) and ShowMessage( Int( 17/3))

    to see how FR makes this calculatiuon.

    And make more tests like below:
    var x :real;
    begin
       x := 17/3;
       ShowMessage( x);
    end;
    

    Mick
  • edited 5:16PM
    Dear Mick

    thank you for you answer
    my code is like below
    procedure Memo23OnBeforePrint(Sender: TfrxComponent);
    var
    b:integer;
    
    begin
      b:=Int( StrToInt(memo10.value) / 3);
      memo23.text:=IntToStr(b)
    
    end;
    

    I can not get decimal result on the code...

    Iam waiting your help...

    regards...
  • edited 5:16PM
    I'm a bit lost [img]style_emoticons/<#EMO_DIR#>/sad.gif" style="vertical-align:middle" emoid=":(" border="0" alt="sad.gif" /> You say you want decimal result, but you still declare[/img]b as int variable.
    Have a look at small example and make some tests:
    procedure Memo2OnBeforePrint(Sender: TfrxComponent);
    var b :real;   // NOT int                                                                  
    begin
      b :=  <Line#> / 3;
      // two different ways to transform the result
      // first                         
      Memo2.Text := VarToStr( b );   // I'm not sure if this works in FR3, as I use FR4
      // second                       
      Memo2.Text := FormatFloat('##0.0#####', b );                                                                                                           
    end;
    

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.