[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now


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

Posted on 2006-05-05
Medium Priority
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)
   tmpB.name = 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

mastoo earned 500 total points
ID: 16614188
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.

Featured Post


Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

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 (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses
Course of the Month19 days, 2 hours left to enroll

834 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