LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default Looping Through Public Collections

I'm learning about collections, which I think will be much better
suited to my large project than working with (and constantly
redimming) arrays.

I've created a collection clTestList in one sub that I want to access
from another sub, so I've dutifully declared it publicly.

Some simplified code:

public clTestList as Collection
dim NewTest as clsRecordSet 'classmodule

set clTestList = New Collection
for i = 1 to 10 'not really but I'm simplifying
set NewTest = New clsRecordSet
NewTest.Name = i
clTestList.Add NewTest
next i

for each NewTest in clTestList
debug.print NewTest.Name
next NewTest

Works fine to here, but when I try to loop through the elements of the
collection from another sub, I can't.

I've tried
For Each NewTest in clTestName (with NewTest also declared as public)
For Each Item in clTestName....
For Each clTestName.Item in clTestName...

the error message varies depending upon what I'm trying. What should
I be doing?

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
For Each and Collections Memento Excel Programming 6 June 4th 07 02:57 PM
Collections of Collections David Morton Excel Programming 6 November 13th 04 01:10 AM
Help with collections ksnapp[_45_] Excel Programming 1 April 7th 04 12:42 AM
Using Collections Kerry[_4_] Excel Programming 1 January 25th 04 04:08 PM
Comparing Collections Tom Ogilvy Excel Programming 1 September 17th 03 06:15 PM


All times are GMT +1. The time now is 10:40 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"