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

  • SEARCH
  • Home
  • 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 199531
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T17:01:54+00:00 2026-05-11T17:01:54+00:00

In VB6, there used to be a Collection data type that would allow retrieval

  • 0

In VB6, there used to be a Collection data type that would allow retrieval of an item in the collection by either its key or its ordinal. However, it wasn’t strongly typed.

Now, with VB.Net, I am looking for a suitable replacement that is strongly type and could be used with a generic collection.

This is a simple example of what I want to do. The only problem is that the underlying collection class, BindingList, does not support efficient retrieval of an item by an alpha key, so I have to loop through the elements to get the item I am looking for. For large collections, this is not efficient.

I have looked though the various Collection type classes and have found no suitable replacement.

This is what I want to do, except for the looping that is done with the Item property.

Rather than just saying “Use Hash tables” or something like that, if you could, please include the detailed out as I have done for the short example below.

Public Class Car

    Public Sub New(ByVal keyName As String, ByVal property1 As String)
        _KeyName = keyName
        _Property1 = property1
    End Sub

    Dim _KeyName As String

    Public Property KeyName() As String
        Get
            Return _KeyName
        End Get
        Set(ByVal value As String)
            _KeyName = value
        End Set
    End Property

    Public _Property1 As String

    Public Property Property1() As String
        Get
            Return _Property1
        End Get
        Set(ByVal value As String)
            _Property1 = value
        End Set
    End Property

End Class

Public Class Cars

    Inherits System.ComponentModel.BindingList(Of Car)

    Public Overloads ReadOnly Property Item(ByVal key As String) As Car
        Get
            For Each CurrentCar As Car In Me.Items
                If CurrentCar.KeyName = key Then
                    Return CurrentCar
                End If
            Next
            Return Nothing
        End Get
    End Property

End Class
  • 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-11T17:01:54+00:00Added an answer on May 11, 2026 at 5:01 pm

    I believe you’re looking for Dictionary<TKey, TValue>. In fact, if you do want your own collection class that’s strongly typed and isn’t (itself) generic, if you change your parent class to Dictionary<string, Car>, you should be all set. This all does, of course, assume that you add the cars to the collection with an explicit string key. If you want the lookup to be based on the value of a property in the collection, you’d do better either using or inheriting from List<Car> and using LINQ to query the list. You could then have…

    Public Overloads ReadOnly Property Item(ByVal key As String) As Car
        Get
            Return (from c in Me where c.KeyName = key select c).SingleOrDefault()
        End Get
    End Property
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 112k
  • Answers 112k
  • 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 I guess this is your problem basically the solution is… May 11, 2026 at 9:59 pm
  • Editorial Team
    Editorial Team added an answer Having diagonal and ratio is enough :-). Let d be… May 11, 2026 at 9:59 pm
  • Editorial Team
    Editorial Team added an answer Error code -2146893819 is hex 80090005 which, in the MS… May 11, 2026 at 9:59 pm

Related Questions

I am working on a VB6 application that uses an ADODB.Recordset object to dump
I was recently put in charge of updating a VB6 data collection app, to
I am converting a VB6 to C# and I want to make my data
I'm trying to use a .NET assembly from VB6 via interop without placing it
I'm a pretty experienced Java programmer that's been doing quite a bit of Win32

Trending Tags

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

Top Members

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.