以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- 遍历集合时遇到的问题 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=91138) |
-- 作者:liangcaixia -- 发布时间:2016/9/30 11:02:00 -- 遍历集合时遇到的问题 请问老师,这段代码该如何修改呀,运行时显示:Collection was modified; enumeration operation may not execute. Dim S7 As new List (of String) For a As Integer = 0 To 9 For b As Integer = 0 To 9 For c As Integer = 0 To 9 S7.Add (CStr(a) & CStr(b) & CStr(c)) Next Next Next For p As Integer = 0 To 2 For g As Integer = 0 To 9 If Tables("ZSHSB1").Rows(p)("S" & CStr(g)) = True Then For Each v As String In S7 If v.Chars(p) = CStr(g) Then S7.Remove(v) End If Next End If Next Next Dim d As String = "" For t As Integer = 0 To (S7.Count-1) d = d & S7(t) & " " Next Tables("ZSHSB1").Rows(0)("BZ") = d |
-- 作者:有点蓝 -- 发布时间:2016/9/30 11:27:00 -- For p As Integer = 0 To 2 For g As Integer = 0 To 9 If Tables("ZSHSB1").Rows(p)("S" & CStr(g)) = True Then For k As Integer = S7.Count - 1 To 0 Step -1 If S7(k).Chars(p) = CStr(g) Then S7.RemoveAt(k) End If Next End If Next Next
|
-- 作者:liangcaixia -- 发布时间:2016/9/30 11:39:00 -- 谢谢老师了,没尝试用removeat,呵呵 |