Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2020 : Report Design
Message Icon Topic: formula Post Reply Post New Topic
Author Message
rptxyz
Newbie
Newbie


Joined: 24 Nov 2007
Online Status: Offline
Posts: 27
Quote rptxyz Replybullet Topic: formula
    Posted: 24 Dec 2007 at 7:56am
text1          text2
text3aaa    text4
if concatening four or more words into two columns and like to make sure column2 texts are lined up. is there any way?.
IP IP Logged
rptxyz
Newbie
Newbie


Joined: 24 Nov 2007
Online Status: Offline
Posts: 27
Quote rptxyz Replybullet Posted: 24 Dec 2007 at 8:17pm

in crystal report 9 i try to put the array of strings into a format but they do not line up neatly.
Local NumberVar d;
Local StringVar array MyArr;
Local NumberVar i;
Local StringVar MyStrLine;
Local StringVar MyStr;
MyStr := "BBBBBBBB-CCCCCCC-DDDD-DDDDAA-AA-DDDDAA-AAA-IIII-LLLLL-NNNNN-YYYYY";
MyArr := Split(MyStr, chr(45));
MyStrLine := trim("");
 
For i := 1 To (UBound(MyArr)) do
(
    MyStrLine := MyStrLine & MyArr;

    if (Remainder(i, 4) = 0) then
    (
        MyStrLine := MyStrLine & chr(10);
    )
    else
    (
        for d := 1 to (15 - Length(MyArr)) do
        (
           MyStrLine := MyStrLine & chr(32)
        );
        MyStrLine
    );
);

MyStrLine

result should line up:
BBBBBBBB    CCCCCCC   DDDD    DDDDAA
AA           DDDDAA     AAA      IIII
LLLLL         NNNNN      YYYYY

        

IP IP Logged
BrianBischof
Admin Group
Admin Group
Avatar

Joined: 09 Nov 2006
Online Status: Offline
Posts: 2458
Quote BrianBischof Replybullet Posted: 24 Dec 2007 at 9:52pm
What font are you using? Most fonts are variable width for each type of character. Try using the Courier font and see if this fixes your problem.
Please support the forum! Tell others by linking to it on your blog or website:<a href="http://www.crystalreportsbook.com/forum/">Crystal Reports Forum</a>
IP IP Logged
rptxyz
Newbie
Newbie


Joined: 24 Nov 2007
Online Status: Offline
Posts: 27
Quote rptxyz Replybullet Posted: 24 Dec 2007 at 11:03pm
thank you. that was it.
IP IP Logged
tconway
Newbie
Newbie
Avatar

Joined: 25 Dec 2007
Location: United States
Online Status: Offline
Posts: 20
Quote tconway Replybullet Posted: 26 Dec 2007 at 10:06am
If you need to use a standard font, such as Arial, another possibility to this is to put the formula in a text box with the correct number of tab stop settings on the text box rather than the string.  Then, instead counting the number of spaces required, insert only a single tab to each break in the string. 
 
For i := 1 To (UBound(MyArr)) do
(
    MyStrLine := MyStrLine & MyArr;
    if (Remainder(i, 4) = 0) then
    (
        MyStrLine := MyStrLine & chr(10);
    )
    else
    (
        MyStrLine := MyStrLine & chr(9)
    );
);
MyStrLine
 
To get this to work properly I had to
1.  Add an empty Text Box
2.  Insert the formula field in it.
3.  Highlight the field and, while the field was highlighted and the textbox in edit mode...
4.  Put tab stops in the correct locations.
 
With the sample above I used 1.25, 2.5 and 3.75.
 
If you have a huge amount of data going in, this may not be best, but it might be worth a try.
 
Tim
 
 


Edited by tconway - 26 Dec 2007 at 10:08am
IP IP Logged
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum



This page was generated in 0.033 seconds.