Results 1 to 6 of 6

scope of objects in a collection

Threaded View

  1. #1
    Forum Contributor
    Join Date
    02-13-2016
    Location
    CT USA
    MS-Off Ver
    office 365 subscription
    Posts
    181

    scope of objects in a collection

    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
    Last edited by whburling; 06-03-2017 at 04:13 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. scope and lifetime of vba objects
    By whburling in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 05-07-2017, 03:41 PM
  2. Replies: 4
    Last Post: 10-30-2015, 01:30 PM
  3. [SOLVED] Performance of iteration through Words collection degrades as collection gets bigger
    By 6StringJazzer in forum Word Programming / VBA / Macros
    Replies: 7
    Last Post: 01-14-2014, 09:44 AM
  4. Replies: 2
    Last Post: 12-23-2011, 11:04 AM
  5. Can I preset what order objects go out of scope?
    By foxguy in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-19-2011, 08:01 PM
  6. Problems storing a Collection within a Collection. Is this possible?
    By Tarball in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-17-2007, 10:47 PM
  7. Passing Objects from Excel VBA collection to a VB6 DLL
    By Dan in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 02-15-2006, 06:35 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1