I've just started to learn how to use classes, so before I explain my problem here, does anyone know of any online resources to learn more about classes in VBA? I read this already: http://www.cpearson.com/excel/Classes.aspx.
Anyway, here's my problem. I've created a class called CStock. It has 5 standard properties (with Get/Let methods) as explained in that article above. Nothing fancy here.
I also want to create a CPortfolio class that has 3 properties: pName, pNumberofPositions, and pHoldings. the first 2 are stardard, but the last one is different. I want it to somehow keep a collection of stocks. I tried putting:
in the CPortfolio module. and then i tried calling:![]()
Private pHoldings As Collection Public Property Get Holdings() As Collection Holdings = pHoldings End Property Public Property Let Holdings(Value As Collection) pHoldings = Value End Property
in a regular sub, but the sub goes into the Get instead of the Let and i get "Complie Error: Argument Not Optional"![]()
port.Holdings.Add stk port.Holdings.Add stk2
Anyone know what I'm trying to do here? Cuz I'm not sure I even know. Also, after I get this working, I want to create a CBook class that holds a bunch of portfolios in the same manner. am i going about this the wrong way?
Thanks,
Joe
Bookmarks