Home |
Search |
Today's Posts |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I still see an asymmetry in the Country and Product classes that
I don't understand. Maybe I need to step back and ask about the overall assumptions. If you really want every product in every country then you don't need collections for each product and country; just two simple collections will do. Like this: ' Assuming the products and countries are listed in a ' worksheet somewhe Dim Products as Collection, Countries as Collection For Each co In ProductRange Products.Add co.Value Next co For each co In CountryRange Countries.Add co.Value Next co Now Products and Countries have everything in them you might need to work with, and if all products are sold in all countries then you don't need Product and Country classes at all. But if you really want to track the countries for each product individually, and/or the products for each country, it must be because you envision the possibility in the future that some products will not be sold in some countries. If so, your idea is sound but I would probably implement it slightly differently. Rather than just tell you how I would do it, I'll go the Socratic route and make you tell me what's not working. I suspect that in the process of describing in more detail what's not happening, you'll see your own processes more clearly. You say what you're doing, but you don't say what's wrong with it...? --- "Fabian" wrote: The error message is in German - it is the runtime error 91. Object not defined or something like that....What is weired to me though, is the fact that the same code runs perfectly fine in VB! Example from VB: Dim p1, p2, pr As Product, c1, c2, co As Country c1 = New Country c2 = New Country p1 = New Product p2 = New Product p1.addCountry(c1) p1.addCountry(c2) p2.addCountry(c1) p2.addCountry(c2) c1.CountryName = "c1" p1.ProductName = "p1" c2.CountryName = "c2" p2.ProductName = "p2" For Each co In p1.Countries MsgBox(co.CountryName) Next For Each pr In c1.Products MsgBox(pr.ProductName) Next |