VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
  Persistable = 0  'NotPersistable
  DataBindingBehavior = 0  'vbNone
  DataSourceBehavior  = 0  'vbNone
  MTSTransactionMode  = 0  'NotAnMTSObject
END
Attribute VB_Name = "Customers"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Option Explicit

Private mCol As Collection

Private Sub Class_Initialize()
   Set mCol = New Collection
End Sub

Private Sub Class_Terminate()
   Set mCol = Nothing
End Sub

Public Function Add(ByVal lID As Long, ByVal sName As String, ByVal sAddress As String) As Customer

   Dim oCustomer As Customer
   
   Set oCustomer = New Customer
   
   With oCustomer
      .ID = lID
      .Name = sName
      .Address = sAddress
   End With
   
   'Convert the ID to a string to make it the key.
   mCol.Add oCustomer, CStr(lID)
   
   Set Add = oCustomer
   
End Function

Public Function ItemByIndex(ByVal lIndex As Long) As Customer
   'When a long is passed to the item method, the item is
   'retrieved by it's index.
   mCol.Item lIndex
End Function

Public Function ItemByKey(ByVal sKey As String) As Customer
   'When a string is passed to the item method, the item is
   'retrieved by it's key.
   mCol.Item sKey
End Function

Public Sub RemoveByIndex(ByVal lIndex As Long)
   'When a long is passed to the remove method, the item is
   'removed by it's index.
   mCol.Remove lIndex
End Sub

Public Sub RemoveByKey(ByVal sKey As String)
   'When a string is passed to the remove method, the item is
   'removed by it's key.
   mCol.Remove sKey
End Sub

Public Function Count() As Long
   Count = mCol.Count
End Function

Public Function NewEnum() As IUnknown
Attribute NewEnum.VB_MemberFlags = "40"
   Set NewEnum = mCol.[_NewEnum]
End Function
