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 3394186
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T04:08:24+00:00 2026-05-18T04:08:24+00:00

I want to know if exist a equivalent of (.net) list<somefixedclass> in vb6 I

  • 0

I want to know if exist a equivalent of (.net)

list<somefixedclass> 

in vb6

I know that exist collection in vb6 but it uses object (variant) instead of a specific object.

thanks.

  • 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-18T04:08:25+00:00Added an answer on May 18, 2026 at 4:08 am

    There is no direct equivalent in VB 6 to the generic List<T> found in VB.NET. However, there is such a thing as a Collection in VB 6, which provides similar functionality. The primary difference is that a VB 6 Collection is not strongly-typed, which means that all objects are stored as Variants in the collection. In some cases, this can be beneficial, because it allows you to store many different types of data in the same collection, and in fact, VB uses this object internally. It’s easy enough to use a Collection and up-cast objects as they are retrieved from the class, but there’s little you can do. It’s not possible to implement strongly-typed collections in the VB runtime.

    That being said, there is a workaround you can implement. Similarly to how collections were implemented in early versions of VB.NET before generics were introduced, you can wrap the Collection in a class, where the only access to the internal Collection is through methods that you expose from this class. This design pattern is commonly referred to as a “custom collection”.

    This does have the benefit of automatically handling casting, and alleviates the consumers of your code from having to remember to mind implementation details like this. It takes care of the (all too likely) possibility that you’ll be looping through a collection at run-time that is only supposed to contain one type of object, but accidentally had a second, incompatible type of object added that causes your code to throw an exception. Of course, the disadvantage is that you have to re-implement most of the functionality already provided by the Collection object yourself, in the form of public methods on your custom collection.

    Here’s an example of how you might go about that:

    Public Class CustomerCollection
    
        ''#Internal collection, exposed by this class
        Private m_Customers As Collection
    
        Private Sub Class_Initialize()
            ''#Set up the internal collection
            Set m_Customers = New Collection
        End Sub
    
        Public Sub Add(ByVal cust as Customer, Optional ByVal key as String)
            ''#Add the Customer object to the internal collection
            If IsMissing(key) Then
                m_Customers.Add cust
            Else
                m_Customers.Add cust, key
            End If
        End Sub
    
        Public Property Get Count() As Integer
            ''#Return the number of objects in the internal collection
            Count = m_Customers.Count
        End Property
    
        Public Sub Remove(ByVal index As Variant)
            ''#Remove the specified object from the internal collection,
            ''# either by its index or its key
            m_Customers.Remove index
        End Sub
    
        Public Function Item(ByVal index As Variant) as Customer
            ''#Return the specified object from the internal collection,
            ''# either by its index or its key
            Set Item = m_Customers.Item(index)
        End Function
    
        Public Sub Clear()
            ''#Removes all objects from the internal collection
            Set m_Customers = New Collection
        End Sub
    
    End Class
    

    Note that in order to set the custom collection’s Item property as the collection’s default method (like the built-in Collection object), you need to follow these steps in the VB 6 IDE:

    1. From the “Tools” menu, click “Procedure Attributes”

    2. Select the name of your custom class from the “Name” combo box.

    3. When the dialog appears, click the “Advanced” button.

    4. Select the “(Default)” item in the “Procedure ID” combo box.

    5. Click “OK”

    If you’d also like to allow enumeration of your custom class using the For Each syntax (also like the built-in Collection object), you can add a NewEnum function to your custom class:

    Public Property Get NewEnum() As IUnknown
        ''#Provides support for enumeration using For Each
        Set NewEnum = m_Customers.[_NewEnum]
    End Property
    

    Once you’ve done that, you need to instruct VB to use this property:

    1. As before, open the “Procedure Attributes” dialog from the “Tools” menu

    2. Select the name of your custom class from the “Name” combo box.

    3. When the dialog appears, click the “Advanced” button.

    4. Type the number “-4” in the “Procedure ID” combo box.

    5. Click “OK”

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

Sidebar

Related Questions

I want to know that can we build a data object using jquery/json, which
I just want to know if there's an approach in VB.NET that can find
I want to know if there exist a form generator that is capable of
I want to know if pointers exist in .NET technology. If yes, is there
i want to know if exist a ideal quantity of testers per programmer. I
I know solutions exist to get HTML / CSS to PDF, but is there
I know services exist such as skyhook, but I simply can not find an
I want to know if Z3 can show equivalent formulas after Quantifier Elimination. Example
I am developing a multi-tenanted asp.net application and want to know if the following
I have a list of values, and want to know which ones don't already

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.