2012-06-14 3 views
6


Нужно отображать серийные номера как римские буквы (i, ii, iii, iv и т. Д.) В моих отчетах о кристаллах. У меня есть серийный номер, записанный как номер записи (1,2,3,4 ...). Так что я должен сделать для него в отчете о кристалле.Отображать серийный номер в виде римских букв в отчетах Crystal Reports

ответ

1

Я не могу взять кредит; Я просто портировать код с this VB Helper article в кристалл, но это было веселое упражнение:

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({[email protected]}); 

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, ""); 

Просто замените мой {[email protected]} параметр заполнитель с переменной, и вы все сделали.

1

Просто используйте функцию Roman(), предоставленную Crystal Report

 Смежные вопросы

  • Нет связанных вопросов^_^