水晶报告公式中的“字符串是非数字的”错误

时间:2012-06-13 13:41:19

标签: crystal-reports

我已经设置了一个公式,用于在水晶报告中屏蔽它后显示字段的值。但它在 cardno 变量中显示错误“字符串是非数字的”。以下是我公式的代码:

StringVar cardno;
NumberVar current_len;
NumberVar card_len;
NumberVar start;
NumberVar last;
StringVar ca;

card_len := ToNumber (Mid ({@lens},1,2));
start    := ToNumber (Mid ({@lens},3,2));
last     := ToNumber (Mid ({@lens},5,2));

current_len := Length (Trim (ToText({CA.CA}, 0 ,'')));

ca := ReplicateString("0",card_len-current_len) + Totext({CA.CA},0,'');

If card_len > current_len Then
    If start = 0 Then
        If last <= 1 Then
            cardno := Mid(ca, last, card_len)            
        Else
            cardno := ReplicateString("X",last-start-1) + Mid(ca, last, card_len)           
Else
    cardno := Mid (ca,1,start) + ReplicateString("X",last-start-1) + Mid(ca, last, card_len);

请提供解决方案以避免此错误。提前谢谢。

1 个答案:

答案 0 :(得分:0)

为什么不做这样的事情:

Select Len({table.field})

//AmEx
Case 15:  Picture({table.field}, "XXXX XXXXXX XXXXX")

//Visa
Case 16:  Picture({table.field}, "XXXX XXXX XXXX XXXX")

Default:  {table.field}

**编辑**

Replace(Space(Len({table.field})-4), " ", "X") + Right({table.field},4)