*

Form Code for Aggregation Mini-Lecture: Day 3

Option Explicit
Private Const OK As Integer = vbOKOnly
Private Const MessageTitle As String = "Pet Care Error"
Private strPetType As String
Private intTypeCare As Integer
Private PetCare As Object 'cannot use WithEvents with Object data type
Private Sub cmdCancel_Click()
    Unload Me
End Sub
Private Sub cmdOK_Click()
    'client-side validation - don't want bad data going in
    If ValidatedInput Then
        'do something here
        Dim intPetType As Integer
        intPetType = lstPetType.ItemData(lstPetType.ListIndex)
        Select Case intPetType
            Case 1 'cat
                Set PetCare = New clsCat 'IUnknown::AddRef
            Case 2 'dog
                Set PetCare = New clsDog 'IUnknown::AddRef
            Case 3 'reptile
                Set PetCare = New clsReptile 'IUnknown::AddRef
            Case 4 'rodent
                Set PetCare = New clsRodent 'IUnknown::AddRef
        End Select
        With PetCare
            .PetType = strPetType
            .CareType = optPetCare(intTypeCare).Caption
            Select Case intTypeCare
                Case 0 'feed
                    MsgBox .Food, OK, "Pet Care"
                Case 1 'clean
                    MsgBox .Cleaner, OK, "Pet Care"
                Case 2 'exercise
                    MsgBox .Exercises, OK, "Pet Care"
                Case 3 'attention
                    MsgBox .Attentions, OK, "Pet Care"
                Case 4 'vet visits
                    MsgBox .VetVisitations, OK, "Pet Care"
            End Select
        End With
        Set PetCare = Nothing 'IUnknown::Release
        'reset values
        lstPetType.ListIndex = -1
        optPetCare(intTypeCare) = False
    End If
End Sub
'Private Sub PetCare_PetCareAdvised(TypePet As String, TypeCare As String)
' 'reset values
' lstPetType.ListIndex = -1
' optPetCare(intTypeCare) = False
'End Sub

Internet Content Rating Association

Alrak's Course Resources ©2002-2007 Karla Carter. All rights reserved. This material (including, but not limited to, Mini-lectures and Challenge Labs) may not be reproduced, displayed, modified or distributed without the express prior written permission of the copyright holder. For permission, contact Karla.