2

こんにちは、Crystal Reports の初心者です。Crystal Reports 2008 を使用しています。文字列内のアルファベット文字を削除して数字だけを残す方法を教えてください。これには機能がありますか?

例: ポイント 231 / ポイント 323 / USP 342 出力: 231 / 323 / 342

ありがとう、Captain16

4

2 に答える 2

3

次の式を使用します

stringvar str;
stringvar str1;
numbervar counter;
numbervar leng;

leng := len({Your_Field});
if leng>0 then
 (
    for counter := 1 to leng do
    (
        If (Mid({Your_Field}, counter, 1)) in "a" to "z" Then
        (
            str1:=str1 + Mid({Your_Field}, counter, 1)
        )
        else
        (
            str := str + Mid({Your_Field}, counter, 1)
        )
    );
str
 ) 


ここではstr、非アルファベットをstr1取得し、指定された文字列からアルファベットのみを取得します。{Your_Field}文字列を含むフィールドまたはパラメーターにすることができます。strそして、アルファベットを印刷することで削除できます...

231 / 323 / 342これは、指定された入力に対して取得している出力です!

これが役に立てば幸いです。試してみて、結果を返してください!

于 2012-10-31T11:07:36.110 に答える
0

Sorry, I can't comment on Hariharan Anbazhagan's code (I don't have enough reputation it seems). It's good code but I would add LCASE to catch all the captial letters.

If LCASE(Mid({?sample}, counter, 1)) in "a" to "z" Then

There's also a IsNumeric() function if you want to identify just the numbers.

于 2012-11-01T11:17:12.893 に答える