Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Saving an object in PropBag

Posted on 1999-07-06
9
Medium Priority
?
370 Views
Last Modified: 2013-12-25
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.
0
Comment
Question by:VikiViking
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 2
  • 2
9 Comments
 

Author Comment

by:VikiViking
ID: 1495013
Edited text of question.
0
 

Author Comment

by:VikiViking
ID: 1495014
Edited text of question.
0
 

Author Comment

by:VikiViking
ID: 1495015
Adjusted points to 120
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 15

Expert Comment

by:ameba
ID: 1495016
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
 

Author Comment

by:VikiViking
ID: 1495017
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
 
LVL 1

Accepted Solution

by:
przemek earned 240 total points
ID: 1495018
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
 

Author Comment

by:VikiViking
ID: 1495019
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
 
LVL 1

Expert Comment

by:przemek
ID: 1495020
Thanks

I think it is not possible.
0
 
LVL 15

Expert Comment

by:ameba
ID: 1495021
For VB5, in "Hardcore VB" there is a PropertyBagX object - but you are better with VB6.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

722 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question