|
-
Jul 6th, 2000, 03:56 AM
#1
Thread Starter
New Member
I must be really thick, but how do i retrive objects froma collection!
i use the following code 2 add 2 a collection
colUsers.Add myNewUserClass, myNewUserClass.UserName
and then the follwoing 2 retirve
Dim myItem As clsUser
For Each myItem In colUsers
MsgBox myItem.UserName
Next
but the above code retrives the repeats the name of the last class i entered. WHere am i going wrong? plz help!
-
Jul 6th, 2000, 04:34 AM
#2
Frenzied Member
this is proboably a byref error, are you passing classes around your code, using set cls1 = cls2 etc.
if you do this you are not making a new copy of the class, both variable names are now pointing to the same object, so when you change the properties of one the properties of the others change.
so what's probably happenning is you are trying to copt the class to however many places you do and adding them to the collection, so everything in the collection is in vact the same object.
in order to copy cls1 to cls2 you have to do something like this
Code:
Set cls1 = New Myclass
cls1.Text = cls2.Text.Property1 'you have to do this for all your properties
it's a bit tedious but you have to do it.
-
Jul 6th, 2000, 05:25 AM
#3
Thread Starter
New Member
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|