Crystal reports 在Crystal报告中将序列号显示为罗马字母

Crystal reports 在Crystal报告中将序列号显示为罗马字母,crystal-reports,crystal-reports-8.5,Crystal Reports,Crystal Reports 8.5,需要在我的水晶报告中以罗马字母(i、ii、iii、iv等)显示序列号。我将序列号捕获为记录号(1,2,3,4…),因此我必须在crystal report中为它做些什么。我不能承担太多的功劳;我只是将代码从移植到Crystal中,但这是一个有趣的练习: NumberVar iCounter := 0; Local StringVar ch := ""; Local NumberVar result := 0; Local NumberVar new_value := 0; Local Numbe



需要在我的水晶报告中以罗马字母(i、ii、iii、iv等)显示序列号。我将序列号捕获为记录号(1,2,3,4…),因此我必须在crystal report中为它做些什么。

我不能承担太多的功劳;我只是将代码从移植到Crystal中,但这是一个有趣的练习:

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, "");
numbervari计数器:=0;
本地StringVar ch:=“”;
本地号码结果:=0;
新_值的本地编号:=0;
本地号码旧_值:=0;
本地StringVar温度:=“”;
temp:=大写({?@Roman});
旧值=1000;
对于iCounter:=1到Len(temp)do
(
//看看下一个角色值多少钱。
ch:=Mid(温度,i计数器,1);
如果ch=“I”,则新值:=1
否则,如果ch=“V”,则新值:=5
否则,如果ch=“X”,则新值:=10
否则,如果ch=“L”,则新值:=50
否则,如果ch=“C”,则新值:=100
否则,如果ch=“D”,则新值:=500
否则,如果ch=“M”,则新值:=1000;
//看看这个角色是否更大
//比前一个好。
如果新值>旧值,则
//新值>上一个值。
//将此值添加到结果中
//再减去前一个两次。
结果:=结果+新值-2*旧值
其他的
//新值只需使用Crystal Reports提供的
Roman()
函数即可