OK, I always get confused about this.
Let’s say I have this code.
Public Sub Bar(byRef pMap as clsMap)
Dim foo as new FooClass()
pMap.listOfFoo.Add(foo)
end Sub
This would mean that referencing ‘Foo’ or the item stored in ‘listOfFoo’ would reference the same object, right? If I was to change a property of ‘foo’ – but not change it to a new object – both would still reference and would reflect the updated values?
Yes, you’re storing a reference pointer to the
fooobject, so if you modify a property in one place, it will be visible in all other places wherefoois referenced.If you want to make a copy of your object, you should consider object cloning.