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