VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
END
Attribute VB_Name = "clsRabbit8"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = True
' Guide to the Perplexed:
' Rabbit8 example
' Copyright (c) 1997 by Desaware Inc. All Rights Reserved

Option Explicit

' The color of the rabbit
Public Color As String

Private m_RabbitNumber As Long

' Which hutch is holding this rabbit?
Private m_Hutch As clsGetContainer8

Public Property Get Number() As Long
    Number = m_RabbitNumber
End Property

' We use a counter in a standard module to
' obtain a count of rabbit objects that have been
' created
Private Sub Class_Initialize()
    RabbitCounter = RabbitCounter + 1
    m_RabbitNumber = RabbitCounter
    ' Assign a randome color
    Select Case Int(Rnd * 3)
        Case 0
            Color = "White"
        Case 1
            Color = "Pink"
        Case Else
            Color = "Grey"
    End Select
    Debug.Print "Rabbit " & m_RabbitNumber & " born."
End Sub

Private Sub Class_Terminate()
    Debug.Print "Rabbit " & m_RabbitNumber & " died."
End Sub

' Inoculates this rabbit
Public Sub Inoculate()
    ' Doesn't actually do anything in this example
End Sub

' Anyone can find out which hutch contains the rabbit
Public Property Get Hutch() As RabbitCollection8
    If m_Hutch Is Nothing Then Exit Property
    Set Hutch = m_Hutch.GetContainer()
End Property

' Only code within the project can set the Hutch for a rabbit
Friend Property Let Hutch(vNewValue As RabbitCollection8)
    If vNewValue Is Nothing Then
        Set m_Hutch = Nothing
        Exit Property
    End If
    Set m_Hutch = vNewValue.GetContainerSubObject()
End Property
