0

在水晶报表中屏蔽字段后,我已经放置了一个公式来显示字段的值。但它在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);

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

4

1 回答 1

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)
于 2012-06-13T20:55:24.273 回答