Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 220
Default Need Class Collection advice

I have been thinking of various ways to populate my collection classes
with its children.


1) I could create the .Add function of the collection class to accept a
child object as an argument, which then adds the child to the collection.

2) I could create the .Add function of the collection class to not
accept any arguments, and to just return a new child object


I do not know when one method would be preferred over the other. Can
anyone help? Thanks!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Need Class Collection advice

I would definitely go with approach #1, if for no other reason is
than it would make your collection class work more like a regular
collection object. I don't see what advantage there would be to
using approach #2.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"R Avery" wrote in message
...
I have been thinking of various ways to populate my collection

classes
with its children.


1) I could create the .Add function of the collection class to

accept a
child object as an argument, which then adds the child to the

collection.

2) I could create the .Add function of the collection class to

not
accept any arguments, and to just return a new child object


I do not know when one method would be preferred over the

other. Can
anyone help? Thanks!



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 220
Default Need Class Collection advice

Alright! Just needed advice from a pro. ;D Thanks.
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 459
Default Need Class Collection advice

I disagree, I'd go for

3) create the .Add function of the collection class to accept any
arguments required to create a child object and return the new child
object

to make it work more like a regular collection *class*. For example,

Set ws = ThisWorkbook.Worksheets.Add(1)

For me, adding a child object directly to the collection is usually a
Private/Friend method of my object hierarchy i.e. not a Public method
exposed to the client.

--

"Chip Pearson" wrote in message ...
I would definitely go with approach #1, if for no other reason is
than it would make your collection class work more like a regular
collection object. I don't see what advantage there would be to
using approach #2.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"R Avery" wrote in message
...
I have been thinking of various ways to populate my collection

classes
with its children.


1) I could create the .Add function of the collection class to

accept a
child object as an argument, which then adds the child to the

collection.

2) I could create the .Add function of the collection class to

not
accept any arguments, and to just return a new child object


I do not know when one method would be preferred over the

other. Can
anyone help? Thanks!


--
Reply
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
pls advice dribler2 Excel Worksheet Functions 0 December 29th 06 02:22 PM
Using a collection class to implement mutliple find/replace strings in cells Bill Hertzing Excel Programming 2 February 18th 04 01:42 AM
Collection Class problems Flemming Dahl Excel Programming 4 February 11th 04 04:41 PM
RaiseEvent from a class contained in a 2nd class collection? Andrew[_16_] Excel Programming 2 January 6th 04 04:22 PM
For/Each iteration for collection class Stelio Excel Programming 1 October 31st 03 12:46 PM


All times are GMT +1. The time now is 01:02 PM.

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

About Us

"It's about Microsoft Excel"