Quantcast
Channel: VBForums - Visual Basic 6 and Earlier
Viewing all articles
Browse latest Browse all 21857

How data are kept into collections

$
0
0
Goodmorning everybody :)

I've a doubt about how Collections kept the data you add to. My questions are from this simple code:
Code:

Dim c As New Collection
Dim cls As New Class1 <- Class1 is a class module within a public var 's' declared as string

cls.s = "Hello"
c.Add cls

cls.s = "Ciao"
c.Add cls

MsgBox c(1).s

My expectancy was the MsgBox returns 'Hello' while it gets back 'Ciao', such as I've overwrite the value of cls property.

What's happened?

It's very important for to solve and I hope someone can help me.
:wave:

Viewing all articles
Browse latest Browse all 21857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>