以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- 多值快速搜索难题 (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=91471) |
||||
-- 作者:nothing -- 发布时间:2016/10/11 16:48:00 -- 多值快速搜索难题
文本框中输入不确定的几个值,怎么分割并搜索表
|
||||
-- 作者:有点蓝 -- 发布时间:2016/10/11 16:55:00 -- Dim sarr() As String = e.Form.Controls("TextBox1").Text.split(" ") Dim filter As String = "1=1" For Each s As String In sarr filter &= " and 第一列 like \'%" & s & "%\'" Next Tables("表A").Filter = filter
|
||||
-- 作者:nothing -- 发布时间:2016/11/5 16:15:00 -- For Each dc As Col In Tables("表A").Cols \'遍历表的所有列 If dc.DataCol.IsDate OrElse dc.DataCol.IsBoolean OrElse dc.DataCol.IsNumeric Then \'如果是时间列,逻辑列,数值列 Continue For \'排除 End If If Filter > "" Then Filter = Filter & " Or " End If For Each s As String In sarr Filter = Filter & " (1=1 and [" & dc.Name & "] Like \'*" & s.Replace("*","[*]").Replace("%","[%]") & "*\')" \'根据控件值迷糊筛选 Next Next Tables("表A").Filter = Filter \'将数据筛选出来 我想将字符列都可以多值模糊搜索,要怎么改,谢谢老师
|
||||
-- 作者:有点蓝 -- 发布时间:2016/11/5 16:29:00 -- Dim sarr() As String = {"a","b","c"} Dim Filter As String = "1=2" For Each dc As Col In Tables("表A").Cols \'遍历表的所有列 If dc.DataCol.IsDate OrElse dc.DataCol.IsBoolean OrElse dc.DataCol.IsNumeric Then \'如果是时间列,逻辑列,数值列 Continue For \'排除 End If \'Filter = Filter & " Or " For Each s As String In sarr Filter = Filter & "or ([" & dc.Name & "] Like \'*" & s.Replace("*","[*]").Replace("%","[%]") & "*\')" \'根据控件值迷糊筛选 Next Next Output.Show(Filter )
|
||||
-- 作者:nothing -- 发布时间:2016/11/5 16:55:00 -- 谢谢老师 我想要的效果: 1.在文本框输入A值,表格中所有字符列筛选出包含A值的记录,但记录比较多,需求进一步搜索 2.再A 后面空格,再输入B值,则在原来搜索出来的基础上再筛选出所有字符列包含B值的记录,可能还需要输入空格C,空格D 二楼是那样的效果了,就是单列的,想扩展到所有的字符列上 |
||||
-- 作者:有点蓝 -- 发布时间:2016/11/5 16:59:00 -- Dim sarr() As String = {"a","b","c"} Dim Filter As String = "1=1" For Each dc As Col In Tables("表A").Cols \'遍历表的所有列 If dc.DataCol.IsDate OrElse dc.DataCol.IsBoolean OrElse dc.DataCol.IsNumeric Then \'如果是时间列,逻辑列,数值列 Continue For \'排除 End If Filter = Filter & " and (" Dim f2 As String = " 1=2 " For Each s As String In sarr f2 = f2 & "or ([" & dc.Name & "] Like \'*" & s.Replace("*","[*]").Replace("%","[%]") & "*\')" \'根据控件值迷糊筛选 Next Filter &= f2 & ")" Next Output.Show(Filter )
|