2015-09-17 29 views
2

循環我有一個集合是這樣的:改變原有的集合,而在VBA

Dim BrokerCol as New Collection 
'Added some data to the Collection 
BrokerCol .Add temp_broker, BROKER_NAME 

而且我通過收集這樣的循環:

For Each collectionitem In BrokerCol 
If ((collectionitem.Bid - bid_average)/bid_average) < pThresholdValue Then 
    'Want to change something here in BrokerCol instead of Collection Item 
Else 
Next collectionitem 

至於說,上面我想改變BrokerCol中的某些內容而不是更改收集項目。我怎麼做?

我嘗試這樣做:

BrokerCol.Item(CollectionItem).Bid = 1 

它給了我一個 '類型不匹配' 錯誤。不知道如何解決這個問題。

+1

什麼是temp_broker?一個東西?您是否嘗試過使用'collectionitem.bid = 1'這是與集合中相同的對象。 –

+0

@TimWilliams可以添加你的評論作爲答案 – lakesh

回答

1

您是否嘗試過只用

collectionitem.bid = 1 

這是相同的對象是集中。

0

你想在BrokerCol中更改什麼?這不是一個標準的vb集合嗎?

+0

我想更改原始集合中的值而不是CollectionItem。 – lakesh