Re: Weird PropertyBag problem, values won't change
- From: "Bob Butler" <tiredofit@xxxxxxxxxx>
- Date: Wed, 25 Jan 2006 05:37:22 -0800
"Andy DF" <nospam@xxxxxxxxxx> wrote in message
news:43d7426f$0$333$5fc30a8@xxxxxxxxxxxxxxx
> Ok, I know what's happening here:
>
> Everytime WriteProperty is called it appends a NEW property, with the
> specified name, EVEN IF IT ALREADY EXISTS!!
> And when ReadProperty is called, it just returns the first property
> with the specified name that it finds.
> Major bug!!!
This is not a bug, it is by design. Try this:
Private Sub Main()
Dim p As PropertyBag
Dim x As Long
Set p = New PropertyBag
For x = 1 To 5
p.WriteProperty "myprop", "value" & CStr(x)
Next
For x = 1 To 5
Debug.Print p.ReadProperty("myprop")
Next
Set p = Nothing
End Sub
It is an easy way to store a list in a propertybag. You can store another
property with the count of items added and then retrieve them all using the
same name. It looks like you are trying to use a property bag like a
collection or dictionary with the property name acting as the key to a
single item and that's just not how the object works. Maybe if you describe
what your real need is somebody can suggest a better way to accomplish it.
--
Reply to the group so all can participate
VB.Net: "Fool me once..."
.
- Follow-Ups:
- Re: Weird PropertyBag problem, values won't change
- From: Andy DF
- Re: Weird PropertyBag problem, values won't change
- References:
- Weird PropertyBag problem, values won't change
- From: Jonathan
- Re: Weird PropertyBag problem, values won't change
- From: Jonathan
- Re: Weird PropertyBag problem, values won't change
- From: Kevin Provance
- Re: Weird PropertyBag problem, values won't change
- From: Andy DF
- Weird PropertyBag problem, values won't change
- Prev by Date: How Hide Application From Process of Taskmgr
- Next by Date: Re: Weird PropertyBag problem, values won't change
- Previous by thread: Re: Weird PropertyBag problem, values won't change
- Next by thread: Re: Weird PropertyBag problem, values won't change
- Index(es):
Relevant Pages
|