以文本方式查看主题
- Foxtable(狐表) (http://foxtable.net/bbs/index.asp)
-- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2)
---- [求助]关于模糊筛选 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=58443)
|
-- 作者:qq469000995
-- 发布时间:2014/10/16 18:16:00
-- [求助]关于模糊筛选
求助大侠:
关于模糊查寻:
有内容为: “ 89米(M/6)— 电脑 ”
现我想模糊输入: “ 89M ” 就能将上面这个输出
不知道如何修改如下代码的?
Dim tnames() As String = { "Table1", "Table2"} With e.Form If e.sender.text <> ""Then For Each tname As String In tnames Dim dst As Table = Tables(tname) Dim txb1 As WinForm.TextBox = .Controls("TextBox1") Dim filter As String = "1=2" For Each dc As DataCol In dst.DataTable.DataCols filter &= " or convert(" & dc.Name & ",\'System.String\') like \'%" & txb1.text & "%\'" Next
dst.Filter = filter Next End If End With
|
-- 作者:有点甜
-- 发布时间:2014/10/16 19:11:00
--
不能这样,除非加空格 89 M
Dim tnames() As String = { "Table1", "Table2"} With e.Form If e.sender.text <> ""Then For Each tname As String In tnames Dim dst As Table = Tables(tname) Dim txb1 As WinForm.TextBox = .Controls("TextBox1") Dim filter As String = "1=2" For Each dc As DataCol In dst.DataTable.DataCols For Each tx As String In txb1.Text filter &= " or convert(" & dc.Name & ",\'System.String\') like \'%" & tx & "%\'" Next Next dst.Filter = filter Next End If End With
|
-- 作者:有点甜
-- 发布时间:2014/10/16 19:16:00
--
写错了。
Dim tnames() As String = { "Table1", "Table2"} With e.Form If e.sender.text <> ""Then For Each tname As String In tnames Dim dst As Table = Tables(tname) Dim txb1 As WinForm.TextBox = .Controls("TextBox1") Dim filter As String = "1=2" For Each dc As DataCol In dst.DataTable.DataCols filter &= " or " Dim ary() As String = txb1.Text.Split(" ") For i As Integer = 0 To ary.Length - 2 filter &= " convert(" & dc.Name & ",\'System.String\') like \'%" & ary(i) & "%\'" filter &= " and " Next filter &= " convert(" & dc.Name & ",\'System.String\') like \'%" & ary(ary.length-1) & "%\'" Next dst.Filter = filter Next End If End With
|
-- 作者:qq469000995
-- 发布时间:2014/10/16 19:26:00
--
老大你帮忙给的代码不能执行呢?
|
-- 作者:有点甜
-- 发布时间:2014/10/16 19:39:00
--
例子发上来。
|
-- 作者:qq469000995
-- 发布时间:2014/10/16 19:42:00
--
老大,收到,谢谢
|