Questions about an object's scope when involved with collections
Lets assume I have a subroutine whose input argument is an empty collection.
Within the subroutine an object is declared and instantiated and then added
to the collection.
When the subroutine returns to the calling program, are the objects within the
collection still in the collection now found in the calling program?
Assume that I did not declare the object being collected as having module scope
but only local scope.
In the old days, forms of global variables were not good practice. But I do not see
how else to preserve the object being collected other than to make its scope at module level
![]()
public sub (ByRef ACollection as collection) Dim A as SpecialObject Set A as new SpecialObject ACollection.add (A) End sub
Bookmarks