zoukankan      html  css  js  c++  java
  • 水晶报表自定义函数(替换并截取特殊字符后内容)

    's待处理的参数
    Function cheakdepart ( s as string)
    '先进行判断
          '声明已知字符串的字节数、">"所在位置的变量
        Dim n As Number  , m As Number
        '声明字符串变量

        Dim s0 as string  

    ‘如果包含">"符号截取其后文本       

            if (">" in s) then    
            For n = 1 To Len(s) '这里用了Len函数来计算已知字符串的字节数
            m = InStr(s, ">", -1) '">"所在的位置(其中的-1是默认的)
            '显示第一个">"后面的字符串
            s0 = Right(s, Len(s) - m)
            next n

            s0=Replace (s0, ">"," " )

    ’否则直接输出

            else
            s0=s
            end if
        cheakdepart =s0

    End Function

    string str="8,9,10,11,12,13";
    string[] count=str.split(',')

    返回的count.length就是6!

     INSTR()函数,有返回值就说名存在

    报告指定的   String   在此实例中的第一个匹配项的索引。  
       
      [Visual   Basic]  
      Overloads   Public   Function   IndexOf(   _  
            ByVal   value   As   String   _  
      )   As   Integer  
       
      [C#]  
      public   int   IndexOf(  
            string   value  
      );  
       
      [C++]  
      public:   int   IndexOf(  
            String*   value  
      );  
       
      [JScript]  
      public   function   IndexOf(  
            value   :   String  
      )   :   int;  
       
      参数  
      value    
      要查找的   String。    
      返回值  

      如果找到该字符,则为   value   的索引位置;如果未找到该字符,则为   -1。如果   value   为   Empty,则返回值为   0。   

    int idx=str.IndexOf(",",0,n);
    string newstr=str.SubString(0,idx);

    newstr就是你想要的.

    ------------------

    那这样儿:

    string[] s=str.Split(',');
    string newstr="";
    for(int iii=0;iii<n;iii++){
    newstr=newstr+s[iii]+",";
    }
    newstr=newstr.Substring(0,newstr.Length-1);


  • 相关阅读:
    PLSQL连接64位oracle,导入导出错误解决办法
    VS2008或者VS2010工具栏,标准里面的 在浏览器中浏览按钮不见了
    jquery radio取值,checkbox取值,select取值 及选中
    Waiting for HOME (‘android.process.acore’) to be launched…解决办法
    GetTickCount() 函数的作用和用法
    MFC ado连接access数据库
    VC切分窗口和多视图
    C++容器——插入与清除
    VC中在对话框上显示图片
    error LNK2005 已经在***.obj中定义
  • 原文地址:https://www.cnblogs.com/glt3260053/p/1393306.html
Copyright © 2011-2022 走看看