R
Rob
I am trying to build a class module that has, among other things, a
collection consisting of items of a user-defined type. VBA is not
cooperating. Let say the type declaration is:
[Private?] Type ItemData
name as String
data1 as double
data2 as double
End Type
In the class module, I set up a collection:
Dim myCollection as New Collection
I want a method to add to the collection, so in the class module:
Sub addItem(nm as String, d1 as Double, d2 as Double)
dim item as ItemData
item.name = nm
item.data1 = d1
item.data2 = d2
myCollection.Add (item)
End Sub
If I put the type declaration in the class module w/o the "Private", an
error says I cannot define a Public user-defined type in an object
module.
If I do use "Private", or if I put the type declaration into a standard
module, it then says that only user-defined type defined in public
object modules can be passed to late-bound functions (is this what is
happening, since I'm using a Collection?)
Can this be done? If so, what's the trick? Any help is appreciated!
collection consisting of items of a user-defined type. VBA is not
cooperating. Let say the type declaration is:
[Private?] Type ItemData
name as String
data1 as double
data2 as double
End Type
In the class module, I set up a collection:
Dim myCollection as New Collection
I want a method to add to the collection, so in the class module:
Sub addItem(nm as String, d1 as Double, d2 as Double)
dim item as ItemData
item.name = nm
item.data1 = d1
item.data2 = d2
myCollection.Add (item)
End Sub
If I put the type declaration in the class module w/o the "Private", an
error says I cannot define a Public user-defined type in an object
module.
If I do use "Private", or if I put the type declaration into a standard
module, it then says that only user-defined type defined in public
object modules can be passed to late-bound functions (is this what is
happening, since I'm using a Collection?)
Can this be done? If so, what's the trick? Any help is appreciated!