Changing values in collections

Moonhawk

New member
Joined
Oct 3, 2007
Messages
2
Programming Experience
Beginner
Hi

I'm having a few problems with this and would be grateful for any help.

I have declared a public collection in a module. I can add and retrieve items to the collection no problem - but I dont seem to be able to change an item in the collection. I am using the collection to store some strings - however once stored the strings appear to be read only.

e.g. the value of cCollection.Item(1) is "Yes" and I want to change it to "No" - I would have thought the following would do it:

cCollection.Item(1) = "No"

however I get a blue line when I type this which says "Property 'item' is 'read only'"

Is it possible to change items in a collection? I would use an array - but I want the ability to use the collection's key property so that I can remove items easily.
 
Last edited:
Are you saying that you've actually created an instance of the Collection class? If so then don't. That's a hold-over from VB6 and serves no useful purpose in new VB.NET code. if you want a collection that will behave as a dynamic array then create an ArrayList.
 
Back
Top