以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  关于表查找的问题  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=51550)

--  作者:kgdce
--  发布时间:2014/5/28 17:14:00
--  关于表查找的问题
 

Find

在指定列中查找指定的字符内容,如果找到,返回行的位置,否则返回-1。
如果Table处在汇总模式下,计算行位置的时候,分组行不包括在内。

语法:

Find(StrFind, RowStart, Col, caseSensitive, fullMatch, Wrap)
Find(StrFind, RowStart, ColName, caseSensitive, fullMatch, Wrap)

下表是参数说明:

 

这只能在一列中查找符合条件的行,并选定行,现在要求是满足两列条件,如何查找呢?

第一列 第二列 第三列

cde    3    w
abc    1   w
cde    5    w
abc    2    q
cde    3    q
abc    1    q
cde    5    q

目的留下符合条件的一行(第一列和第三列组合为一个名称,对组合后的名称要求第二列留下最大的行,其它行移除)

Dim Customers As List(Of String())
Customers = DataTables("表A").GetValues("第一列|第三列")
For Each Customer As String() In Customers


Dim s As Integer
Dim t As Integer
With CurrentTable
    Dim r As Integer
    r = .Find("abc", 0, 0, False, False, True)
    If r > - 1 Then \'如果找到符合条件的行
        .Position = r  \'则选择该行
        t=CurrentTable.Current("第二列")
    Else
    End If
    Do While  .Compute("count(第一列)",CurrentTable.Current("第一列")="abc")<>1
        Dim Result As DialogResult
        Result = MessageBox.Show(r, "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
        If Result = DialogResult.Yes Then
            Exit Do
        End If
        s = .Find("abc", .RowSel + 1, 0, False, False, True)
        If s > - 1 Then \'如果找到符合条件的行
            .Position = s  \'则选择该行
            messagebox.show( "s" & s)
            If  CurrentTable.Current("第二列")<=t Then
                messagebox.show("t" & t)
                CurrentTable.Current.Remove
            Else
                CurrentTable.Rows(r).remove
                r=s-1
            End If
        End If
    Loop
End With
Next


--  作者:Bin
--  发布时间:2014/5/28 17:15:00
--  
看这里,下面的语法二这个例子 http://www.foxtable.com/help/topics/0553.htm