字符串的IndexOf难道不能解决这个问题吗?

解决方案 »

  1.   

    dim s as string
    s = "1|2|3|4|5|"
    if s.indexof("2") <> -1 then
       ' 存在
    end if
      

  2.   

    dim str as string
    str = "1|2|3|4|5|"
    if ("|" + str).indexof("|2|",0) >= 0  then
    '在字符串中
    end if
      

  3.   

    遇到过这样的问题.用String的Indexof,不好分如23或123
    用数组可以这样的"
       Dim myString As String="1|2|3|4|5|"
       Dim myArr As Array=Split(myString,"|")
       If myArr.IndexOf(myArr,"2")<>-1 Then
        ;;;;;;;包含
       End if