Adding user defined types to a collection object 
Author Message
 Adding user defined types to a collection object

Folks.

can I add a total user defined type to a collection object? I've defined the
type, and I can set values eg MyType.X=2 etc. I can add individual elements
of the type to a collection as in:

MyColl MyType.X "WHATEVER"

What I want to do is have something like:

MyColl MyType "THE_WHOLE_THING"

Is it possible? I get a runtime error if I try the second statement.

Advice appreciated?

Thanks

Peter



Tue, 26 Mar 2002 03:00:00 GMT  
 Adding user defined types to a collection object
Peter

The VB6 MSDN help clearly states that collections cannot contain UDTs.  However,
they can contain UDTs that are assigned to variants, but - if you try to assign
a UDT to a variant you find that it can only be done if the.UDT is defined in a
public object module, the simplest of which would be a class in a DLL
(Instancing set to other than Private).  So....

You could create a DLL, define you UDT in the class of the DLL, reference the
DLL in your standard EXE, assign your UDT to a variant and add the variant to
your collection.  However, you might at this point decide that it is easier to
use a collection instead of a UDT, and then uses a collection of collection
objects, or to use a class instead of your UDT and use a collection of class
objects.

John.....

John..........

Quote:

> Folks.

> can I add a total user defined type to a collection object? I've defined the
> type, and I can set values eg MyType.X=2 etc. I can add individual elements
> of the type to a collection as in:

> MyColl MyType.X "WHATEVER"

> What I want to do is have something like:

> MyColl MyType "THE_WHOLE_THING"

> Is it possible? I get a runtime error if I try the second statement.

> Advice appreciated?

> Thanks

> Peter



Tue, 26 Mar 2002 03:00:00 GMT  
 Adding user defined types to a collection object

Quote:

>Folks.

>can I add a total user defined type to a collection object? I've defined the
>type, and I can set values eg MyType.X=2 etc. I can add individual elements
>of the type to a collection as in:

>MyColl MyType.X "WHATEVER"

>What I want to do is have something like:

>MyColl MyType "THE_WHOLE_THING"

>Is it possible? I get a runtime error if I try the second statement.

>Advice appreciated?

>Thanks

>Peter

use a class instead of a UDT.


Tue, 26 Mar 2002 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Adding User-Defined Type to a Collection Object

2. newbie question: cannot Add User-defined type data to a Collection

3. VB5: ByRef Error when adding user-defined type to Collection

4. Adding a User defined type to a Collection

5. Adding a user defined type to a collection

6. User Defined Interfaces and Collection Objects in Business Object Hierarchy

7. User Defined Interfaces and Collection Objects in Business Object Hierarchy

8. User-Defined Type not allowed in a collection

9. user-defined types in Collections

10. Classes, Collections, and User Defined Types

11. Collection of user-defined type?

12. collection of a user-defined type: problems

 

 
Powered by phpBB® Forum Software