mhdhallak
asked on
something wrong with collections
Why doesn't Visual Basic let me add a user defined type structure variable to a collection?
Whenever i try to do that it gives me this compile error message:
"Only user-defined types defined in public object modules can be coerced to or from a variant or pressed to late-bound functions."
Please note that I defined my type strcture in public module. This error happens on this statement
Notes.Add Item:=newnote, Key:=Str(CurNote)
'newnote' is the variable that is declared as type structure. And 'Notes' is my collection.
Any idea?
Whenever i try to do that it gives me this compile error message:
"Only user-defined types defined in public object modules can be coerced to or from a variant or pressed to late-bound functions."
Please note that I defined my type strcture in public module. This error happens on this statement
Notes.Add Item:=newnote, Key:=Str(CurNote)
'newnote' is the variable that is declared as type structure. And 'Notes' is my collection.
Any idea?
ASKER
Adjusted points from 10 to 20
ASKER
Erick37,
I read that page but it doesn't quite help me because it deals more with activex servers you create. In my case, i am dealing with Collection. I can't possible modify that because it's built in Visual Basic.
so what do you think i should do?
Anybody?
I read that page but it doesn't quite help me because it deals more with activex servers you create. In my case, i am dealing with Collection. I can't possible modify that because it's built in Visual Basic.
so what do you think i should do?
Anybody?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
The standard Collection object will accept any value that can be stored in a Variant. Unfortunately you cannot store a UDT in a Variant.
If you must use the standard Collection object the only alternative is to convert your UDT to a Class as suggested by Ark.
If you must use the standard Collection object the only alternative is to convert your UDT to a Class as suggested by Ark.
http://support.microsoft.com/support/kb/articles/Q184/8/98.ASP