以文本方式查看主题

-  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=124348)

--  作者:bahamute
--  发布时间:2018/9/4 20:52:00
--  请教:嵌套循环判断删除行出错(已解决)
报错:不能通过已删除的行访问该行的信息。

Dim bol2 As Boolean
For i As Integer = t.Rows.Count -1 To 0 Step -1
    bol2 = False
    Dim r As Row = t.Rows(i)
    If r.IsNull("核实情况_情况类别") = False Then
        For Each item As String In nms
            If nms.Contains(r("核实情况_情况类别")) = False Then     \'nms为集合
                bol2 = True
                Exit For
            Else
                r.Delete()
            End If
        Next
        If bol2 Then
            Continue For
        End If
    End If
Next
[此贴子已经被作者于2018/9/4 20:59:26编辑过]

--  作者:有点蓝
--  发布时间:2018/9/4 20:59:00
--  
代码在什么事件?

Dim bol2 As Boolean
For i As Integer = t.Rows.Count -1 To 0 Step -1
    bol2 = False
    Dim r As Row = t.Rows(i)
    If r.IsNull("核实情况_情况类别") = False Then
        For Each item As String In nms
            If nms.Contains(r("核实情况_情况类别")) = False Then     \'nms为集合
                bol2 = True
            Else
                r.Delete()
            End If
            Exit For
        Next
        If bol2 Then
            Continue For
        End If
    End If
Next

--  作者:bahamute
--  发布时间:2018/9/4 21:01:00
--  
逻辑出了点错误,删除操作早了异步,已解决,多谢。
Dim bol2 As Boolean
For i As Integer = t.Rows.Count -1 To 0 Step -1
    bol2 = False
    Dim r As Row = t.Rows(i)
    If r.IsNull("核实情况_情况类别") = False Then
        For Each item As String In nms
            If nms.Contains(r("核实情况_情况类别")) = False Then
                bol2 = True
                Exit For
            End If
        Next
        If bol2 Then
            Continue For
        Else
            r.Delete()
        End If
    End If
Next