以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  任意设置筛选条件  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=179410)

--  作者:wugang0131
--  发布时间:2022/8/22 16:05:00
--  任意设置筛选条件
请教蓝老师,一段用于筛选的代码如下:

With e.Form.Controls("xingming")
    If .Value IsNot Nothing Then
        If Filter > "" Then
            Filter = Filter & " And "
        End If
        Dim txt As String = "\'%" & .Value & "%\'"
        Filter = Filter & "(姓名 Like " & txt & " )"
    End If
End With
With e.Form.Controls("xingbie")
    If .Value IsNot Nothing Then
        If Filter > "" Then
            Filter = Filter & " And "
        End If
        Dim txt As String = "\'%" & .Value & "%\'"
        Filter = Filter & "(性别 Like " & txt & " )"
    End If
End With
With e.Form.Controls("danwei")
    If .Value IsNot Nothing Then
        If Filter > "" Then
            Filter = Filter & " And "
        End If
        Dim txt As String = "\'%" & .Value & "%\'"
        Filter = Filter & "(工作单位 Like " & txt & " )"
    End If
End With

这段代码可对“姓名”、“性别”、“工作单位”三个条件进行组合筛选,但是组合筛选只能是“And”。我的问题是,如果添加一个组合框,含有“And”和“Or”两个组合设置,使代码在“And” 或 “Or” 之间任意改变设置。该如何写代码?谢谢

--  作者:有点蓝
--  发布时间:2022/8/22 16:20:00
--  
dim ar as string = " " &  e.Form.Controls("andor选择组合框").text & " "

With e.Form.Controls("xingming")
    If .Value IsNot Nothing Then
        If Filter > "" Then
            Filter = Filter & ar
        End If
        Dim txt As String = "\'%" & .Value & "%\'"
        Filter = Filter & "(姓名 Like " & txt & " )"
    End If
End With

--  作者:wugang0131
--  发布时间:2022/8/24 15:52:00
--  
谢谢蓝老师!