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

Decimal Tab like Solution

edited April 2002 in General
Is there any method or displayformat which let me print field as below :


1.0
2.2
3.13
100.4


which like word decimal tab

thanks in advance.

Comments

  • edited April 2002
    There is no display format that would accomplish this, however you can
    override the string formating in the GetText event of the field and format
    the string yourself. For example:

    procedure TForm1.ppDBText1GetText(Sender: TObject; var Text: String);
    var
    lsFront: String;
    lsBack: String;
    liIndex: Integer;
    begin
    liIndex := Pos('.', Text);
    lsFront := Copy(Text, 1, liIndex - 1);
    lsBack := Copy(Text, liIndex + 1, Length(Text) - liIndex);

    liIndex := Length(lsBack);
    while (liIndex > 1) do
    begin
    if (lsback[liIndex] = '0') then
    lsBack[liIndex] := '#'
    else
    break;
    end;

    for liIndex := 0 to 5 - Length(lsFront) - 1 do
    lsFront := '#' + lsFront;

    for liIndex := 0 to 5 - Length(lsback) - 1 do
    lsBack := lsBack + '#';

    Text := Concat(lsFront, Concat('.', lsBack));

    end;

    This example assumes that the field is 11 characters long, a single trailing
    zero, and a maximum of 5 trailing decimals places. Replace # with space or
    any other padding character.

    --
    Cheers,

    Alexander Kramnik
    Digital Metaphors

This discussion has been closed.