Remove the Alphabet in Crystal Report

落爺英雄遲暮 提交于 2019-12-12 21:46:13

问题


Hi I'm new in Crystal Reports, I'm using Crystal Reports 2008 and I would like to know if how can I remove the alphabet characters in string and only the numbers will remain. Is there function for this?

example: Point 231 / Point 323 / USP 342 output: 231 / 323 / 342

Thanks, Captain16


回答1:


Use the following formula

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
 ) 


Here the str will get the non-alphabets and str1 will get you only the alphabets from the given string. {Your_Field} can be your field or parameter which contains the string. And by printing str alphabets can be removed...

231 / 323 / 342 this is the output I'm getting for your given input !

Hope this helps, Try and get back with results !




回答2:


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.



来源:https://stackoverflow.com/questions/13151683/remove-the-alphabet-in-crystal-report

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!