I have a class module called Holding. In it are several public variables. My code is this:
Dim holdings as Collection
Dim h as Hold开发者_高级运维ing
Set holdings = new Collection
For i = 1 to last
Set h = new Holding
h.x = y
'... etc
holdings.Add(h)
Next i
This gives me error "object doesnt support this property or method" on the holdings.Add(h)
line, but everywhere I look, it gives this exact example of how to achieve this. What am I missing?
Remove the parentheses.
holdings.Add h
Otherwise you are trying to add to the collection the value of the default property of your Holding
instance, and it doesn't have a default property.
精彩评论