How to use collection in VB6

Posted on 2009-02-18
Last Modified: 2013-11-25
I'm trying to understand how Collections work In VB...and the references are not exactly helpful

I've created a library class  (lLibrarynfo) where each class has the following
ID- string
Name - Name of the Library
Connection - Ste SQL Server 5 Connection string to the library
DocPath - the path on the network where the libray Documents are

I've created a collection called CLXLibraries which contains the LibraryInfo Classes
So that I have a Collection of Libraries

I've created, initialized and added 13 libraries to the collection
Let I have the following
LibrayAlpha with values
ID = 10
Name =" Alpha Library"
And whatever db connecion sttring

I have the following routine that I use to pass each library to be added to the collection
Public Sub AddLibToColl(ByRef ThisLibInfo As TempLibrayInfo)
    CLXLibraries.Add ThisLibInfo.ID, ThisLibInfo.Name, ThisLibInfo.Connection, ThisLibInfo.DocPath, CLXLibraries, CStr(ThisLibInfo.ID)
End Sub

If I want to retrieve and use the infomation for this library How is this done
I've  Tried CLXLibraries.item("10)  and this does not work

The purpose of the program is to have the user select what ever  SQLDB (called a Libray) and run some operations against it

Question by:keptins
    LVL 32

    Accepted Solution

    To add:

    'To Add
    Public Sub AddLibToColl(ByRef ThisLibInfo As TempLibrayInfo)
        CLXLibraries.Add ThisLibInfo, CStr(ThisLibInfo.ID)
    End Sub
    'To Retrieve:
    dim ThisLibInfo as TempLibraryInfo
    set ThisLibInfo = CLXLibraries.item("10") 

    Open in new window


    Author Closing Comment


    Featured Post

    How to improve team productivity

    Quip adds documents, spreadsheets, and tasklists to your Slack experience
    - Elevate ideas to Quip docs
    - Share Quip docs in Slack
    - Get notified of changes to your docs
    - Available on iOS/Android/Desktop/Web
    - Online/Offline

    Join & Write a Comment

    Suggested Solutions

    How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
    When we want to run, execute or repeat a statement multiple times, a loop is necessary. This article covers the two types of loops in Python: the while loop and the for loop.
    This video teaches viewers about errors in exception handling.
    Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

    729 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

    18 Experts available now in Live!

    Get 1:1 Help Now