以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  [求助]For Each 求解  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=76202)

--  作者:农村人
--  发布时间:2015/10/23 14:58:00
--  [求助]For Each 求解
Dim ds As String = "TF-15001"
For Each r As Row In Tables("表A").Rows
    If r("第二列") = ds Then
        r.Delete
    End If
Next

执行以上代码,并没有一次删除指定条件的行.这是因为什么?如何修改呢

--  作者:狐狸爸爸
--  发布时间:2015/10/23 15:41:00
--  

我测试没有问题啊。

 

要不你改一下:

 

Dim ds As String = "TF-15001"
For Each i As Integer = Tables("表A").Rows.Count -1 to 0 Step - 1
    Dim r As Row = Tables("表A").rows(i)
    If r("第二列") = ds Then
        r.Delete
    End If
Next

--  作者:农村人
--  发布时间:2015/10/24 13:37:00
--  
这代码有问题,不能正确执行
--  作者:Hyphen
--  发布时间:2015/10/24 14:34:00
--  

把Each 去掉

 

Dim ds As String = "TF-15001"

For i As Integer = Tables("表A").Rows.Count -1 to 0 Step - 1
Dim r As Row = Tables("表A").rows(i)
If r("第二列") = ds Then
r.Delete
End If
Next