Home General
New Blog Posts: Merging Reports - Part 1 and Part 2

Formatting a number

edited March 2002 in General
I am wondering if you can help me with this:

I have a DBText field that is a float and I need to change it to a
specifically formatted String. The final format is 5 number slots and no
decimal places eg
25.25 = 02525
5.01 = 00501
100.00 = 10000

I have been playing around with FormatString and FormatTextMask, but the
only way I can get this to work is to have different cases for the general
class of number ie:

Var

x:Variant;

y:String;

begin

x := Round(Report['Permanent Impairment Percent']*100);

IF x>='1000' then

if x<='9999' then

begin

y:= FloatToStr(x);

Value:=Copy(FormatMaskText('\00000;0;0', y),0,5);


end;

x := Round(Report['Permanent Impairment Percent']*100);

IF x>='10' then

if x<='999' then

begin

y:= FloatToStr(x);

Value:=Copy(FormatMaskText('\0\0000;0;0', y),0,5);


end;

x := Round(Report['Permanent Impairment Percent']*100);

IF x='10000' then


begin

y:= FloatToStr(x);

Value:=Copy(FormatMaskText('00000;0;0', y),0,5);


end;



end;



As you can see, quite ugly! Do you have any suggestions as to how else I
can tackle this?

Comments

This discussion has been closed.