Link to home
Start Free TrialLog in
Avatar of VikiViking
VikiViking

asked on

Saving an object in PropBag

Within a UserControl, I want to use a self-made-object GColumns. This object has been compiled as an ActiveX-dll. Now I wish to save this GColumns-object in the PropertyBag of the UserControl, because I need the values which are stored in it. The values of the GColumns-object are filled at design-time.
This is the problem:
Using either PropBag.WriteProperties or PropBag.ReadProperties results in an runtime error: (-2147467262 "System Error &H80004002 Interface not supported").
I also tried to create the GColumns-object in the same project as the usercontrol, but this didn't work either.
The GColumns-object is not used as a property. This should not be a problem, because other variables can be stored in the PropBag easily. Other standard objects cannot be stored in the PropBag, so maybe I'm just having trouble finding the right way.
Hopefully someone has the brains to answer me.
Avatar of VikiViking
VikiViking

ASKER

Edited text of question.
Edited text of question.
Adjusted points to 120
Dim pb As New PropertyBag
Dim oGColumns As GColumns
pb.WriteProperty "VIKI", oGColumns.object

Dim oGColumns As Object ' or GColumns
Set oGColumns = pb.ReadProperty("VIKI")

Be sure to check this in compiled version (not in IDE).
Well, AMEBA, thanks for your answer, but this doesn't work for me. I've seen the code you've given me on MSDN, but I'm afraid that this is not going to work under VB5. It seems not to be possible to declare a variable as "New PropertyBag". Maybe it works with VB6. I haven't had the time to try this on another machine.
Furthermore, I used the compiled version (I didn't try that yet), but that gives the same error.
ASKER CERTIFIED SOLUTION
Avatar of przemek
przemek

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Okay, przemek, I had been thinking of a solution like this, with the difference that I wanted to write it to some file. However, this is quite a job, because the GColumns-collection contains a lot of properties and one or more collections again. And the number of collections it contains is not constant.
So I'm afraid I just skip my search for this problem and try it with VB6 (still didn't have the time). Because I appreciate your proposed solution, I would like to give you the half of the points. Is that possible?

Thanks

I think it is not possible.
For VB5, in "Hardcore VB" there is a PropertyBagX object - but you are better with VB6.