views:

19

answers:

1

I am designing a program behind excel and using VBA 6.5. I am having some problems with the built in dictionary object. I understand the basics and have found numerous examples on how to add simple data to them but I'm more concerned with custom objects.

My problem: I have an object with several constructors - X, Y, Yf, A, P, etc. Now there are many of these objects that need to be collected. I have tried using a simple Collection class for these objects but have read that Dictionaries are quicker and when dealing with as many of these objects I need the program to run as quickly as possible.

Basically, how do you add a custom object to a dictionary object

Dim testDict as Dictionary
Dim myObj as CustomObject
Dim myObj2 as CustomObject

Set testDict = New Dictionary
Set myObj = New CustomObject
Set myObj2 = New CustomObject

testDict.Add(0, myObj)
testDict.Add(1, myObj2)
A: 

I have found you can actually do this! But now I have a new problem! Lets say I want to access the X property of the CustomObject class.

testDict.Item(0).X = 5

I would really like the intellisense to pick up on the properties I have assigned to the clsas. I know this is possible if you create your own custom collection class but how do you do it within a dictionary? Is it possible to create your own dictionary class? If so, can someone give me the basics or a resource.

Adam