|
-
Dec 5th, 2002, 10:18 PM
#1
Thread Starter
Need-a-life Member
Damn Collections
Can anyone explain me why do I get thousands of identical items even if I change the item that I'm loading??
Emiliano F. Martín
If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
Encourage the person who helped you to keep doing it, and give him the points he deserves.
MP3 Organizer: Freeware to logically organize all your MP3s.
-
Dec 5th, 2002, 10:20 PM
#2
Can you expand on that a little?
Laugh, and the world laughs with you. Cry, and you just water down your vodka.
Take credit, not responsibility
-
Dec 5th, 2002, 10:22 PM
#3
Thread Starter
Need-a-life Member
Originally posted by crptcblade
Can you expand on that a little?
VB Code:
pRS.Add pFields, CStr(rs(IDIndex))
pRS is a collection, and pFields is a class. No matter that I change the values of this class. And add them. I get all the previous records change with the last one I've loaded.
Emiliano F. Martín
If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
Encourage the person who helped you to keep doing it, and give him the points he deserves.
MP3 Organizer: Freeware to logically organize all your MP3s.
-
Dec 5th, 2002, 10:38 PM
#4
Fanatic Member
That's weird.
u sure ur pFields isn't always pointing to the same thin' or ur
rs(IDIndex) hadn't any problemo?
ASM,C,C++,BASIC,VB,JAVA,VBS,HTML,ASP,PHP,mySQL,VB.NET,MATLAB
Programming is fun, but only if you're not on a tight deadline 
So I consider all those working engineers sad people
VB FTP class
3 page PHP crash course
Crash Course on DX9 Managed with VB.NET covering basics till terrain creation
-
Dec 5th, 2002, 10:41 PM
#5
Thread Starter
Need-a-life Member
No... try it and you'll see.
Emiliano F. Martín
If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
Encourage the person who helped you to keep doing it, and give him the points he deserves.
MP3 Organizer: Freeware to logically organize all your MP3s.
-
Dec 5th, 2002, 10:44 PM
#6
Thread Starter
Need-a-life Member
Emiliano F. Martín
If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
Encourage the person who helped you to keep doing it, and give him the points he deserves.
MP3 Organizer: Freeware to logically organize all your MP3s.
-
Dec 5th, 2002, 10:46 PM
#7
Originally posted by Mc Brain
Can you post it?
I think I might know the issue.
Here is the code that behaves correctly
VB Code:
Private Sub Command1_Click()
Dim c As New Collection
Dim cls As Class1
Dim x As Integer
For x = 1 To 10
Set cls = New Class1
cls.i = x
cls.s = "Test" & x
c.Add cls, x & x
Next
For Each cls In c
Debug.Print cls.i, cls.s
Next
Set c = Nothing
End Sub
Here is the code that doesn't work correctly
VB Code:
Private Sub Command1_Click()
Dim c As New Collection
Dim cls As Class1
Dim x As Integer
Set cls = New Class1
For x = 1 To 10
cls.i = x
cls.s = "Test" & x
c.Add cls, x & x
Next
For Each cls In c
Debug.Print cls.i, cls.s
Next
Set c = Nothing
End Sub
Does yours look similar to the second?
Laugh, and the world laughs with you. Cry, and you just water down your vodka.
Take credit, not responsibility
-
Dec 5th, 2002, 10:53 PM
#8
Thread Starter
Need-a-life Member
It looks like the second one. And I know that the first one works... but I need to get it working with the second one.
Why does it do this??
Emiliano F. Martín
If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
Encourage the person who helped you to keep doing it, and give him the points he deserves.
MP3 Organizer: Freeware to logically organize all your MP3s.
-
Dec 5th, 2002, 10:55 PM
#9
Because you are not adding actual objects to the collection, just the reference to it. Since you are not setting a new reference, it will continuously update the original object.
Laugh, and the world laughs with you. Cry, and you just water down your vodka.
Take credit, not responsibility
-
Dec 5th, 2002, 10:56 PM
#10
Thread Starter
Need-a-life Member
Emiliano F. Martín
If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
Encourage the person who helped you to keep doing it, and give him the points he deserves.
MP3 Organizer: Freeware to logically organize all your MP3s.
-
Dec 5th, 2002, 10:57 PM
#11
Why is it that you can't do it the first way?
Laugh, and the world laughs with you. Cry, and you just water down your vodka.
Take credit, not responsibility
-
Dec 5th, 2002, 11:01 PM
#12
Thread Starter
Need-a-life Member
Because it's not as easy as your example. Each item has 76 different values. What's more... this 76 values are a collection which is generated on run-time. So, for each item (that I want to add to the main collection) I'd need to create this "object". If there are a few, there's no problem. But, when the number is huge.... the computer goes dead!!! (I mean the resources)
Emiliano F. Martín
If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
Encourage the person who helped you to keep doing it, and give him the points he deserves.
MP3 Organizer: Freeware to logically organize all your MP3s.
-
Dec 5th, 2002, 11:05 PM
#13
Okay, so you add the first, then change a value or two, then try to add it as a second, and so forth?
Hmmm...I really don't know of any other way around. Sorry.
Laugh, and the world laughs with you. Cry, and you just water down your vodka.
Take credit, not responsibility
-
Dec 5th, 2002, 11:06 PM
#14
Thread Starter
Need-a-life Member
I had the "first way" before.... but I need to change it because it's too slow.
Emiliano F. Martín
If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
Encourage the person who helped you to keep doing it, and give him the points he deserves.
MP3 Organizer: Freeware to logically organize all your MP3s.
-
Oct 25th, 2007, 08:03 AM
#15
Junior Member
Re: Damn Collections
crptcblade, thank you very much. Had the same problem today
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
|