How to use collection in VB6

Posted on 2009-02-18
Medium Priority
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

Daniel Wilson earned 1000 total points
ID: 23671275
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

ID: 31548286

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month14 days, 2 hours left to enroll

807 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