Board index » delphi » convert str to integer in QReport

convert str to integer in QReport

Im trying to convert part of a string to an integer using Quick Report
TQRExpr.
 Copy(table.colm,2,2) will get the characters but if the first character is
an 0 then I don't want it displayed.

i.e. 02 but I only want 2 to show on the report.
Thanks for the help.
Dianne
dia...@pcsonline.com

 

Re:convert str to integer in QReport


Hi Dianne,

I don't trust the QuickReport functions.(Visible, refresh..nothing works)
Also TQRExpr works half and half.
I set always the Font.Color:=clWhite instead of Visible:=false;

In your case:
 //this shows integers without leading 0.
   QRText1.Caption:= IntToStr(StrToInt(Copy(table.colm,2,2)));

Rudy
==============================================================

Quote
Dianne wrote:

> Im trying to convert part of a string to an integer using Quick Report
> TQRExpr.
>  Copy(table.colm,2,2) will get the characters but if the first character is
> an 0 then I don't want it displayed.

> i.e. 02 but I only want 2 to show on the report.
> Thanks for the help.
> Dianne
> dia...@pcsonline.com

Re:convert str to integer in QReport


On Wed, 31 Mar 1999 10:23:40 -0500, "Dianne" <dia...@pcsonline.com>
wrote:

Quote
>Im trying to convert part of a string to an integer using Quick Report
>TQRExpr.
> Copy(table.colm,2,2) will get the characters but if the first character is
>an 0 then I don't want it displayed.

>i.e. 02 but I only want 2 to show on the report.

If you only want the first two characters of the string then this
might work.

Use TQRDBEdit instead (TQRExpr is overkill?).
Put this line on the OnPrint event of the TQRDBEdit:

        Value := IntToStr( StrToInt( Copy( Value, 1, 2 )));

If you want to use strings longer than 2 characters then obviously you
might want to drop the Copy function. Good luck!

/Hung

Other Threads