Suppose in a Customer Order system you have an OrderItem class and an order
items collection class called OrderItemCol
In order to read OrderItem out of the collection, you would do:
Private Sub Class_Initialize()
Set mcolOrderItem = New Collection
End Sub
Sub ....' Your procedure name
Private mcolOrderItem As Collection
Dim objOrderItem As OrderItem
Dim lngIndex As Long
For lngIndex = mcolOrderItem.Count To 1 Step -1
Set objOrderItem = mcolOrderItem.Item(lngIndex)
With objOrderItem
'Put the code to read the members
End With
Next lngIndex
End sub
Notes: make sure you implement the COUNT and ITEM member functions which
will wrap VB collection count and Item member functions.
-----Original Message-----
From: Fredrick J. Krantz [mailto:krunch97@m...]
Sent: Friday, August 25, 2000 11:29 PM
To: professional vb
Subject: [pro_vb] collections and classes combined
Dear: John Smiley
I have 3 of your books (beginning,examples and objects) I
have gone thru
the object book. I really like the concept, but am lost
with using the
collection when i need to get an object out of the
collection. I have
added and removed objects in the collection fine, only need
to retrieve the
information out of it.
Can you give a snippett of code that can help.
I have been reviewing your book for the last 2 weeks to get
this new object
and collection down cause I will be using it at work along
with integrating
crystal reports and oracle. This all is very exciting, but
need this vital
piece to put everything together like a puzzle.
thanks krunch97
ps: waiting for that web book you're writing.