Catia VBA to .CATScript for type “Collection”

前端 未结 2 703
借酒劲吻你
借酒劲吻你 2021-01-24 15:37

In my VBA code i\'m using the following:

Dim docsToSave As Scripting.Dictionary
Set docsToSave = New Scripting.Dictionary

Dim toRemove As Collection
Set toRemov         


        
2条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-24 16:00

    Either you have to use arrays, and manage the resizing yourself as you add and delete items to/from it, or you can use a dictionary and manage the keys as integers. I usually do the latter.

    'create dictionary
    set dict = CreateObject("Scripting.Dictionary")
    
    'add object
    dict.add dict.count,objectOrValue
    
    'loop
    for i = 0 to dict.count -1
       objectOrValue = dict.item(i)
       ...
    next
    

    This should behave much like a zero-based collection if you want to keep the one-based behavior of the vba collection use "dict.count+1" as the key

提交回复
热议问题