By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,083 Members | 1,957 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,083 IT Pros & Developers. It's quick & easy.

Updating a property of an Object within a collection of Objects

P: n/a
Is there any way to do this without removing the object and then re-adding it
with the updated property.

Public Structure Blob
Public f1 as String
Public f2 as Boolean
End Structure

I then have a collection of Blobs defined and add 5 elements to the
collection. I then want to be able to loop through the collection and
possibly change the f2 flag to true in certain situations.
Mar 18 '06 #1
Share this Question
Share on Google+
5 Replies


P: n/a
KenRoy,

You can change the Boolean in the same place. You never can change a string
in the same place.
However why bother about that?

Cor

"KenRoy" <Ke****@discussions.microsoft.com> schreef in bericht
news:2E**********************************@microsof t.com...
Is there any way to do this without removing the object and then re-adding
it
with the updated property.

Public Structure Blob
Public f1 as String
Public f2 as Boolean
End Structure

I then have a collection of Blobs defined and add 5 elements to the
collection. I then want to be able to loop through the collection and
possibly change the f2 flag to true in certain situations.

Mar 18 '06 #2

P: n/a
Hi!

Try:

For each o as Blob in oBlobColl
if o.f1="Charly" then o.f2=true
next

HTH

Wolfgang

"KenRoy" <Ke****@discussions.microsoft.com> schrieb im Newsbeitrag
news:2E**********************************@microsof t.com...
Is there any way to do this without removing the object and then re-adding
it
with the updated property.

Public Structure Blob
Public f1 as String
Public f2 as Boolean
End Structure

I then have a collection of Blobs defined and add 5 elements to the
collection. I then want to be able to loop through the collection and
possibly change the f2 flag to true in certain situations.

Mar 18 '06 #3

P: n/a
Any way to do it directly if I know the Index of the collection with out
cycling through?

"Hauer Wolfgang" wrote:
Hi!

Try:

For each o as Blob in oBlobColl
if o.f1="Charly" then o.f2=true
next

HTH

Wolfgang

"KenRoy" <Ke****@discussions.microsoft.com> schrieb im Newsbeitrag
news:2E**********************************@microsof t.com...
Is there any way to do this without removing the object and then re-adding
it
with the updated property.

Public Structure Blob
Public f1 as String
Public f2 as Boolean
End Structure

I then have a collection of Blobs defined and add 5 elements to the
collection. I then want to be able to loop through the collection and
possibly change the f2 flag to true in certain situations.


Mar 18 '06 #4

P: n/a
I error out when I try to use the following logic:
Dim b as blob
Dim blobs as New Collection

b.f1="A"
b.f2=False
blobs.Add(b)
b.f1="B"
b.f2=False
blobs.Add(b)
b.f1="C"
b.f2=False
blobs.Add(b)

blobs(2).f2=True
"Cor Ligthert [MVP]" wrote:
KenRoy,

You can change the Boolean in the same place. You never can change a string
in the same place.
However why bother about that?

Cor

"KenRoy" <Ke****@discussions.microsoft.com> schreef in bericht
news:2E**********************************@microsof t.com...
Is there any way to do this without removing the object and then re-adding
it
with the updated property.

Public Structure Blob
Public f1 as String
Public f2 as Boolean
End Structure

I then have a collection of Blobs defined and add 5 elements to the
collection. I then want to be able to loop through the collection and
possibly change the f2 flag to true in certain situations.


Mar 18 '06 #5

P: n/a
Shure!

Dim oBloColl as ListOf(Blob)
....

If oBlobCol(0).f1 ="..."

"KenRoy" <Ke****@discussions.microsoft.com> schrieb im Newsbeitrag
news:2B**********************************@microsof t.com...
Any way to do it directly if I know the Index of the collection with out
cycling through?

"Hauer Wolfgang" wrote:
Hi!

Try:

For each o as Blob in oBlobColl
if o.f1="Charly" then o.f2=true
next

HTH

Wolfgang

"KenRoy" <Ke****@discussions.microsoft.com> schrieb im Newsbeitrag
news:2E**********************************@microsof t.com...
> Is there any way to do this without removing the object and then
> re-adding
> it
> with the updated property.
>
> Public Structure Blob
> Public f1 as String
> Public f2 as Boolean
> End Structure
>
> I then have a collection of Blobs defined and add 5 elements to the
> collection. I then want to be able to loop through the collection and
> possibly change the f2 flag to true in certain situations.


Mar 18 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.