Addressing object in a collection

Hap

Well-known Member
Joined
Jul 20, 2005
Messages
647
The following code is giving me an "Invalid procedure call or argument" error. The code is a class object "aCanopy" that contains a collection of "Members". Each member class also contains a collections of "Triangles". I can address the properties of the Members just fine but the error occurs whenever I try to access a Triangle in the Triangles collection.

Code:
Sub jUpdate()
Dim i As Long
Dim j As Long
Dim k As Long
Dim ws3 As Worksheet
Dim Row As Range
Dim m As Member
Dim t As Triangle
Dim s As Triangles
Dim p As Nodes
Set ws3 = Sheets("3D Data")
If Not ws3.Cells(20, 3).Value Then Exit Sub
k = aCanopy.Members.Item(1).Triangles.Count
Set s = aCanopy.Members.Item(1).Triangles
For i = 1 To k
    Set t = s.Item(i)
    Call aTri(i, t.UnitNormalVector.z, t.p1.x, t.p1.y, t.p2.x, t.p2.y, t.p3.x, t.p3.y, 100, 100, 100)
Next i
End Sub


The following is the Get statement in the Triangles class:

Code:
Public Property Get Item(ByVal Value As String) As Triangle
    Set Item = cTriangles(Value)
End Property

Any help would be greatly appreciated.

Thank you
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
If you change the property get procedure so that the argument is a variant rather than a string, it should solve the problem. The argument needs to serve as both a key for the collection and an ordinal index.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top