Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 276119
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T00:52:12+00:00 2026-05-12T00:52:12+00:00

I am trying to retrieve the correct value from an ArrayList of objects (.NET

  • 0

I am trying to retrieve the correct value from an ArrayList of objects (.NET 1.1 Framework):

I have the following defined:

Public AlList As New ArrayList

Public Class ItemInfo
    Public ItemNo As Int16
    Public ItemType As String
    Public Reports As Array
    Public PDFs As Array
End Class

The form_load event code contains:

Dim AnItemObj As New ItemInfo

Then a loop that includes:

AnItemObj.ItemNo = AFile.RecordId
AnItemObj.ItemType = temp
AlList.Add(AnItemObj)

So I should now have an ArrayList of these objects, however if I try to retrieve the data:

MsgBox(AlList(5).ItemNo)

I always get the ItemNo of the last value in the list.

What am I missing?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T00:52:12+00:00Added an answer on May 12, 2026 at 12:52 am

    Put the following code:

    Dim AnItemObj As New ItemInfo
    

    inside the loop which adds AnItemObj to the list.

    When you add a reference type to a list, you are only adding the reference, not the value.

    This means that if you add 10 times the same instance to a list, it will add 10 times the same reference to the list. But if afterward you still have a reference to this instance you can modify its properties and as all 10 entries in the list point to the same reference in memory, all 10 entries will be modified.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 489k
  • Answers 489k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer move to WPF........ May 16, 2026 at 8:59 am
  • Editorial Team
    Editorial Team added an answer You will probably want to use the SHBrowseForFolder API. There… May 16, 2026 at 8:59 am
  • Editorial Team
    Editorial Team added an answer +[NSThread sleepForTimeInterval:] is more likely to do what you want… May 16, 2026 at 8:59 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I am trying to login and retrieve status information from a HTTPS URL via
I have a list of key/value pairs I'd like to store in and retrieve
What is the best way of handling trying to get data from a DataReader
I'm trying to call a PostgreSQL stored procedure from a Java app; the procedure
I would like to write an simple application able to retrieve some certain data
Trying to get the hang of using OOP in Perl. My problem is that
I am working on PHP & mySQL based website. I am trying to setup
I have been studying unicode and its Python implementation now for two days, and
I'm building a Java Lucene-based search system that, on addition, adds a certain number

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.