以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  CurrentTable  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=138029)

--  作者:yifan3429
--  发布时间:2019/7/21 12:18:00
--  CurrentTable
下面的代码是根据当前表来搜索的,我想检索的是 当前窗口的Table1  怎么表示呢




If e.sender.Text.Contains("[") OrElse e.sender.Text.Contains("\'") OrElse e.sender.Text.Contains("*") OrElse e.sender.Text = "回车查询筛选" Then
    Return
End If
Dim Values As New List (Of String)
Dim fltstr() As String
Dim txt As String = e.sender.Text
Dim flt As String
For Each c As Col In CurrentTable.Cols
    If c.DataCol.IsString AndAlso c.Name <> "拼音" Then
        Values.Add(c.Name)
    End If
Next
If Values.Count = 0 Then
    Return
End If
txt = txt.Trim()
If txt = "" Then
    flt = ""
Else
    If txt.Contains(",") Then
        fltstr = txt.split(",")
        Dim i As Integer = InStrRev(txt,",")
        Dim py As String = txt.SubString(i)
        py = "\'*" & py & "*\'"
        For Int As Integer = 0 To Values.Count - 1
            If CurrentTable.Cols(Values(Int)).DataCol.IsString = False Then
                Continue For
            End If
            For Index As Integer = 0 To fltstr.Length - 1
                If Int = Index Then
                    flt = flt & Values(Int) & " Like \'*" & fltstr(Index) & "*\'" & " And "
                Else
                    Continue For
                End If
            Next
        Next
        flt = Left(flt,flt.Length - 5)
        If CurrentTable.Cols.Contains("拼音") Then
            flt = flt & " Or 拼音 Like " & py
        End If
    Else
        txt = "\'*" & txt & "*\'"
        For Int As Integer = 0 To Values.Count - 1
            If CurrentTable.Cols(Values(Int)).DataCol.IsString = False Then
                Continue For
            End If
            flt = flt & Values(Int) & " Like " & txt & " Or "
        Next
        flt = Left(flt,flt.Length - 4)
        If CurrentTable.Cols.Contains("拼音") Then
            flt = flt & " Or 拼音 Like " & txt
        End If
    End If
End If
CurrentTable.Filter = flt

--  作者:y2287958
--  发布时间:2019/7/21 15:50:00
--  
Tables("窗口1_Table1")
--  作者:有点蓝
--  发布时间:2019/7/21 21:08:00
--  
看看:http://www.foxtable.com/webhelp/topics/1547.htm
--  作者:yifan3429
--  发布时间:2019/7/23 11:30:00
--  
CurrentTable  还是不会替换到窗口所有表    
                            CurrentTable

For Each c As Col In e.form.tablename.Cols
    If c.DataCol.IsString AndAlso c.Name <> "拼音" Then
        Values.Add(c.Name)
        MessageBox.Show(c.Name )
    End If
Next


--  作者:有点蓝
--  发布时间:2019/7/23 11:49:00
--  
For Each c As Col In e.form.controls("Table1").table.Cols