Updating a property of an Object within a collection of Objects

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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.
 
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
 
Hi!

Try:

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

HTH

Wolfgang
 
Any way to do it directly if I know the Index of the collection with out
cycling through?
 
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
 
Shure!

Dim oBloColl as ListOf(Blob)
....

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top