Home Component Writing

Label9OnGetText " is not a valid Integer value

Hi,
I am getting this message when trying to print report..... ( Could not run program: Label9OnGetText " is not a valid Integer value )...... how can I fix this?????
Below is the code of label9ongettext. please thanks
object raProgramInfo2: TraProgramInfo
raClassName = 'TraEventHandler'
raProgram.ProgramName = 'Label10OnGetText'
raProgram.ProgramType = ttProcedure
raProgram.Source = 'procedure Label10OnGetText(var Text: String);'#13#10'begin'#13#10#13#10' Text' + ' := (IntToStr(StrToInt(DBCalc1.Text) +'#13#10' '#9' StrTo' + 'Int(DBCalc2.Text) +'#13#10' StrToInt(DBCalc3.Text' + ')) ;'#13#10#13#10'end;'#13#10
raProgram.ComponentName = 'Label10'
raProgram.EventName = 'OnGetText' raProgram.EventID = 53 end
Thanks Rajeev

Comments

  • Hi Rajeev,

    This issue is in your RAP code. An empty string '', is not a valid integer so when you make a call to StrToInt with an empty string, the error will occur. Check the value of the DBCalc(s) before converting them to an integer. Also, I highly recommend using an intermediate variable to hold the integer sum before converting back to text.
    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited January 2023
    Hi Nico,

    This is the formula which we are assigning in Label9OnGetText procedure.

    procedure Label9OnGetText(var Text: String);
    begin
    Text := (IntToStr(StrToInt(DBText2.Text) +
    StrToInt(DBText3.Text) +
    StrToInt(DBText4.Text)) ;
    end;

    As we are new in Report builder can you help on this to rewrite it.

    Thanks
    Rajeev
  • edited January 2023
    Depending on the type of field value you are accessing with your DBText components, it is better to access the data directly from the database (pipeline).

    Also, since you are making calculations, I suggest using the OnCalc event of a TppVariable rather than the OnGetText of a TppLabel (which is extremely inefficient). Be sure to set the variable type to an Integer

    Assuming your fields are Integer types...
    procedure Variable1OnCalc(var Value: Variant);
    begin

    Value := MyPipeline['MyField1'] + MyPipeline['MyField2'] + MyPipeline['MyField3'];

    end;
    I suggest taking a look at the main RAP demo provided with ReportBuilder. This will give you a good idea how to us RAP code and the various features. Demo #1 shows how to make a calculation using a variable and pipeline values.
    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • Hi Nico,
    I will try this and let you know.Thanks for quick reply and support.

    Thanks
    Rajeev
Sign In or Register to comment.