QuickReport TQRExpr Control

Can anyone please give me an example of how to access the value of a TQRExpr in code. I need to check the expression result.
Who is Participating?
ZonnaldConnect With a Mentor Commented:

the TQREXpr has a OnPrint method.
You can look at the value (string) that is to be printed and using the val(String,Float,Result) procdure you can compare it to floating point values etc...

Procedure myForm.myExprPrint(sender: TObject;
  var Value: String);
var tc : integer;
     Fval : Double;
     val(Value,Fval,tc);  (* convert string to floating point *)
     if tc = 0 then          (* convert ok *)
        if checkthevalue(FVal) = resultNotOK then
           Value := '0';       (* or something *)

Hows that?

atkinslgAuthor Commented:
An even better way is the one sent to me by Christopher Miller:

The "Value" property of a TQRExpr comonent is of type TQREvResult, which is
defined in qrprntr.pas.

You can check "Value.Kind" to see what the datatype is.  The following
table shows how to retrieve the results of the expression based on the
value of "Value.Kind"

   If Value.Kind = resInt then the results of the expression are in

   If Value.Kind = resDouble then the results of the expression are in

   If Value.Kind = resString then the results of the expression are in
Value.StrResult (defined as string[255])

   If Value.Kind = resBool then the results of the expression are in

   If Value.Kind = resError then the expression had an error

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.