Display Serial Number as Roman letters in Crystal Reports
Asked Answered
C

3

6


need to display serial no as roman letters(i,ii,iii,iv etc) in my crystal reports. I have the serial number captured as record number (1,2,3,4...).so what i have to do for it in crystal report.

Cobbie answered 14/6, 2012 at 8:17 Comment(0)
G
2

Just use the Roman() function provided by Crystal Reports

Gluteal answered 4/3, 2015 at 7:10 Comment(0)
G
1

I can't take much of the credit; I simply ported the code from this VB Helper article into Crystal, but it was a fun exercise:

NumberVar iCounter := 0;
Local StringVar ch := "";
Local NumberVar result := 0;
Local NumberVar new_value := 0;
Local NumberVar old_value := 0;
Local StringVar temp := "";

temp := UpperCase({?@Roman});

old_value = 1000;

For iCounter := 1 To Len(temp) do
(
    // See what the next character is worth.
    ch := Mid(temp, iCounter, 1);

    if ch = "I" then new_value := 1
    else if ch = "V" then new_value := 5
    else if ch = "X" then new_value := 10
    else if ch = "L" then new_value := 50
    else if ch = "C" then new_value := 100
    else if ch = "D" then new_value := 500
    else if ch = "M" then new_value := 1000;

    // See if this character is bigger
    // than the previous one.
    If new_value > old_value Then
        // The new value > the previous one.
        // Add this value to the result
        // and subtract the previous one twice.
        result := result + new_value - 2 * old_value
    Else
        // The new value <= the previous one.
        // Add it to the result.
        result := result + new_value;

    old_value := new_value;
);

// Format the number without commas or decimals
ToText(result, 0, "");

Simply replace my {?@Roman} parameter placeholder with your variable, and you're all set.

Gibrian answered 25/6, 2012 at 23:24 Comment(0)
P
0

I tried to fix it [enter image description here][1]

<https://www.tek-tips.com/viewthread.cfm?qid=887691>

or

<https://www.tek-tips.com/viewthread.cfm?qid=1613334>

and

<https://www.youtube.com/watch?v=X_UaulmICtM&list=TLPQMTUwMjIwMjMRAYZJzCsXDQ&index=6>

specifically: at crystal report

TH1: Fomula fields/new/"nameabc"/enter/"Roman(GroupNumber)"/ ctrl+S/and pull it out

TH2: Fomula fields/new/"nameabc"/enter/

 select GroupNumber

 case 1 : "   I"

 case 2 : "  II"

 case 3 : " III"

 case 4 : "  IV"

 case 5 : "   V"

 case 6 : "  VI"

 case 7 : " VII"

 case 8 : "VIII"

 case 9 : "  IX"

 case 10 : "   X"

 case 11 : "  XI"

 case 12 : " XII"

 case 13 : "XIII"

 case 14 : " XIV"

 case 15 : "  XV"

 case 16 : " XVI"

 case 17 : "XVII"
default : ""

/ ctrl+S/and pull it out

But it really doesn't help t so there will be this 3 case (t improved from link 2-3) it can apply to the 3rd or even 10th group of headings

TH3: ex: (you want to create a text message for group 3) Formula fields/new/"nameabc"/enter/ "

WHILEPRINTINGRECORDS;
GLOBAL NUMBERVAR INTSTTGRTEST;
INTSTTGRTEST :=0;

/ ctrl+S/ drag it out and put it in heading group 2 and hide it (= right click/format field/common/ check Suppress/ok) you can go to link 3 to see

Formula fields/new/"nameabcd"/enter/ "

WHILEPRINTINGRECORDS;
GLOBAL numbervar INTSTTGRTEST := INTSTTGRTEST + 1;
stringvar y;
STRINGVAR ARRAY X := ["A","B","C","D","E","F","G","H","I","J","K", "L","M","N","O","P","Q","R","S","T","U","V","W","X ","Y","Z"];
if INTSTTGRTEST <= 26 then (
redim preserve X[INTSTTGRTEST];
y := X[INTSTTGRTEST]
);
y;

/ ctrl+S/and pull it out and place it at group 3

and the alphabet can be whatever we want. ex:


X := ["I","II","III","IV","V","VI","VII","VIII","IX","X","XI" ,"XII","XIII","XIV","XV","XVI","XVII","XVIII","XIX","XX","XXI","XXII","XXIII"," XXIV","XXV","XXVI","XXVII","XXVIII","XXIX","XXX","XXXI","XXXII","XXXIII","XXXIV","XXXV","XXXVI" ,"XXXVII","XXXVIII","XXXIX","XL","XLI","XLII","XLIII","XLIV","XLV","XLVI","XLVII","XLVIII"," XLIX","L"];

or


X := ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]; 

hope it can help you

enter code here  [1]: https://i.sstatic.net/OeBBQ.png
Pulchi answered 15/2, 2023 at 8:59 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.