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.
VikiVikingAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

VikiVikingAuthor Commented:
Edited text of question.
0
VikiVikingAuthor Commented:
Edited text of question.
0
VikiVikingAuthor Commented:
Adjusted points to 120
0
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

amebaCommented:
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).
0
VikiVikingAuthor Commented:
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.
0
przemekCommented:
Try this:

Private Sub ReadPropertyGColumns(PropBag As PropertyBag)
    Dim gc As GColumns
    Dim i As Long
    Dim Name As String
   
    On Error Resume Next
    i = 1
    Do While (True)
        Name = PropBag.ReadProperty("gc" & CStr(i) & "Name", "")
        If (err.Number <> 0) Then Exit Do
        Set xf = m_colGColumns.Add(Name)
        gc.Prop1 = PropBag.ReadProperty("gc" & CStr(i) & "Prop1", "")
        gc.Prop2 = PropBag.ReadProperty("gc" & CStr(i) & "Prop2", "")
        i = i + 1
    Loop
    On Error GoTo 0
End Sub

Private Sub WritePropertyGColumns(PropBag As PropertyBag)
    Dim gc As GColumns
    Dim i As Long
   
    On Error Resume Next
    i = 1
    For Each gc In m_colGColumns
        Call PropBag.WriteProperty("gc" & CStr(i) & "Name", xf.Name)
        Call PropBag.WriteProperty("gc" & CStr(i) & "Prop1", xf.Prop1)
        Call PropBag.WriteProperty("gc" & CStr(i) & "Prop2", xf.Prop2)
        i = i + 1
    Next gc
    On Error GoTo 0
End Sub

Private Sub UserControl_ReadProperties(PropBag As PropertyBag)
    Call ReadPropertyGColumns(PropBag)
End Sub

Private Sub UserControl_WriteProperties(PropBag As PropertyBag)
    Call WritePropertyGColumns(PropBag)
End Sub

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
VikiVikingAuthor Commented:
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?

0
przemekCommented:
Thanks

I think it is not possible.
0
amebaCommented:
For VB5, in "Hardcore VB" there is a PropertyBagX object - but you are better with VB6.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.