Okay, I'm probably missing something very obvious, but I want to use a collection to store a bunch of user-defined types.
Here's a cutdown version of what I want to accomplish:
The compiler chokes on the red line saying:
So I changed the Type scope to public, then tried to move the Type statement from a form module (where code was originally) to a new standard module, explicitly casting my UDT to a variant with CVar(), then move the entire code, but to no avail, getting same error each time.
I really would much rather that I use a collection to store my UDTs, so any insights would be much appreciated.
Here's a cutdown version of what I want to accomplish:
Code:
Private Type PropertyInfo
pName As String
pType as String
pValue as Variant
End Type
Private ctlProperties as Collection
Private Sub foo(ctl As Control)
Dim prp as Property
dim CtlPrp as PropertyInfo
Set ctlProperties = New Collection
For each prp in ctl.Properties
CtlPrp.pName = prp.Name
CtlPrp.pType = prp.Type
CtlPrp.pValue = prp.Value
'Add this to the collection
[color=red]ctlProperties.Add CtlPrp, CtlPrp.Name[/color]
Next prp
End Sub
The compiler chokes on the red line saying:
Only user-defined types defined in public object modules can be coerced to or from a variant or passed to late-bound functions
So I changed the Type scope to public, then tried to move the Type statement from a form module (where code was originally) to a new standard module, explicitly casting my UDT to a variant with CVar(), then move the entire code, but to no avail, getting same error each time.
I really would much rather that I use a collection to store my UDTs, so any insights would be much appreciated.