By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,678 Members | 1,411 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,678 IT Pros & Developers. It's quick & easy.

How to do this in VB.NET

P: n/a
This isn't the perfect solution, but you could do
a .Remove to empty the collection and then re-use it.
-----Original Message-----

I'm trying to create a collection of objects,
I seam to be unable to re declare the object e.g.
Set aObject = New Class1 therefore I get a collection of
objects all of which are the same....

Dim aObject as Class1
Dim cCollection as New Collection

Set aObject = New Class1
aObject.Property = "A"
cCollection.Add aObject

' Here are the new lines
Set aObject = Nothing
Set aObject = New Class1

aObject.Property = "B"
cCollection.Add aObject

Debug.Print cCollection.Item(1).Property ' Shows "A"
Debug.Print cCollection.Item(2).Property ' Shows "B"



Jul 19 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.