'myfreemind: (3楼)
删除存在的选择集 If ThisDrawing.SelectionSets.Count > 0 Then For i = 0 To ThisDrawing.SelectionSets.Count - 1 ThisDrawing.SelectionSets.Item(i).Clear ThisDrawing.SelectionSets.Item(i).Delete Next End If
--------------------
上面的 item (i) 中的 i 好象 要改成 常数 0
是这样的,删除集合时,会引起集合中的数目变化。
For i = 0 To ThisDrawing.SelectionSets.Count - 1 ThisDrawing.SelectionSets.Item(i).Clear ThisDrawing.SelectionSets.Item(i).Delete Next
比如:本来集合中的数目是5个,删除1个之后只有4个了,但计数器i的循环次数依然没有改变,是从0-4的,因而后面的就会出错,因为已经不存在了。
For i = ThisDrawing.SelectionSets.Count - 1 To 0 ThisDrawing.SelectionSets.Item(i).Clear ThisDrawing.SelectionSets.Item(i).Delete Next
计数器i的循环是从4-0的,所以没有影响。