0
我有一个列表,我正在使用它来存放一个命令队列。未从列表中删除的项目
我需要遍历队列中的每个项目,执行命令,随着它们一起删除它们。
项目未从队列中删除。
这里是一个快速测试代码不工作,要么:
Dim MyList As New List(Of String)
For i = 0 To 5
MyList.Add(i)
Next
MsgBox(MyList.Count) 'returns 6
MyList.Remove(2)
MyList.Remove(4)
For i = 0 To MyList.Count - 1
MsgBox(MyList(i)) 'pops up 6 times, including the 2 "deleted" ones.
Next
MsgBox(MyList.Count) 'still returns 6
的项目不被删除。
正如有队列类型的替代; '队列 .Dequeue' –
你的快速测试代码不会做你所描述的。只有4条消息“弹出”,最后一个消息框弹出4. – LarsTech
另外,在查看您的问题历史记录后,请阅读元网站上关于标题中标签使用的帖子:[应该包括“标签”在他们的标题?](http://meta.stackexchange.com/questions/19190/should-questions-include-tags-in-their-titles) – valverij