以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  集合请教  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=53373)

--  作者:hbhb
--  发布时间:2014/7/6 17:04:00
--  集合请教
大师:劳驾帮助写一代码

有一字动态的字符串集合“a、b 、c、d、e、f”  
转换成条件表达式filter的 or语句
如果是d、e 跳过连接,但d、e客户有可能写成D、e1 ,其实是一个意思。如何写此代码?


--  作者:有点甜
--  发布时间:2014/7/6 17:11:00
--  

 代码

 

Dim str As String = "a,b,e,f,g,h,o,D,e1,E"
Dim filter As String = "1=2"
For Each s As String In str.Split(",")
    If s.StartsWith("d") = False AndAlso s.StartsWith("e") = False AndAlso s.StartsWith("D") = False AndAlso s.StartsWith("E") = False Then
        s = s.SubString(0, 1)
        filter &= " or 第一列 like \'" & s.ToLower & "*\' or 第一列 like \'" & s.ToUpper & "*\'"
    End If
Next
msgbox(filter)