Thread: Multiciplicity
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Bob Bridges[_2_] Bob Bridges[_2_] is offline
external usenet poster
 
Posts: 257
Default Multiciplicity

To get intelligent replies from folks, you really need to say more than "it
didn't work", they need you to tell them what it DID do -- error message,
garbled response, whatever. But I can at least attempt a comment or two,
he

In the below code you have an AddCountry method which adds the argument c to
the Countries collection. But instead of saying Countries.Add, it says
Me.Countries.Add; why? What is Me? I've seen it done, but I've never been
clear on what Me is even in Access, much less in Excel.

I think if you change that code to just "Countries.Add c" you'll have added
the country object or code or whatever it is to your Countries collection.
But then your code adds the statement "c.Products.Add Me", which seems to
assume that the Products collection is a property of the country (and I don't
know why it would be), and it's adding Me to the Products as though Me is a
product. Well, maybe it is, but I don't know where your code would be
getting it.

Let's review your requirements, because I'm not su You want a Countries
collection to contain one entry for every country, right? And a Products
collection to hold one of every product? Or do you need something like every
combination of country and product (because if you do, I would probably
create it a different way)?

Maybe we should start he What do you want to DO with these things? How
do you want to use them?

--- "Fabian" wrote:
I've got two user-defined classes, Country and Product. Every product is
sold in every country, therefore the countries should contain a collection of
products (reference) and vice versa. So I wrote:

*** class product
Public Countries As Collection

Private Sub Class_Initialize()
Set Countries = New Collection
End Sub

Public AddCountry(ByRef c As Country)
Me.Countries.Add c
c.Products.Add Me
End Property

*** class country
Public Products As Collection

Private Sub Class_Initialize()
Set Products= New Collection
End Sub

But that doesn't seem to work at all. What am I doing wrong?