Home
Forums
New posts
Search forums
Articles
Latest reviews
Search resources
Members
Current visitors
Newsgroups
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Home
Forums
Newsgroups
Microsoft Excel
Microsoft Excel Programming
User-defined type collection in class module
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="Rob, post: 8431860"] 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! [/QUOTE]
Verification
Post reply
Home
Forums
Newsgroups
Microsoft Excel
Microsoft Excel Programming
User-defined type collection in class module
Top