Simple question about changing a value of an object in a collection

Posted on 2006-05-05
Last Modified: 2010-04-23
I have this code

class Foo

Structure b
    dim id as integer
    dim name as string
end structure

private coll as new collection

pubic sub SetName (name as string, idKey as integer)
   dim tmpB as b

   tmpB = coll(idKey) = name

end sub

Assuming that the collection already as a bunch of "b" structures in it and I want to change the name variable, the SetName function doesn't work. It pulls the correct struct out based on the id key but the name doesn't permenantly change. How do you make the data save back in the collection?

Or is there a better way to do this?

Question by:rutledgj
    1 Comment
    LVL 21

    Accepted Solution

    Structures are value-types, as opposed to reference.  To keep using a structure, you'd have to remove the original and add the modified value back to the collection much like you would an integer value.  Or if you used a class instead of a structure, your example would work.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Top 6 Sources for Identifying Threat Actor TTPs

    Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

    Article by: jpaulino
    XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String ( Literal, only instead of starting and ending with w…
    If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
    This video discusses moving either the default database or any database to a new volume.
    In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor ( If you're interested in additional methods for monitoring bandwidt…

    779 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

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now