 |
Form Code for Aggregation Mini-Lecture: Day 2
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 WithEvents PetCare As clsPetCare
Private Sub cmdCancel_Click()
Unload Me
End Sub
Private Sub cmdOK_Click()
If ValidatedInput Then
Set PetCare = New clsPetCare
With PetCare
.PetType = strPetType
.CareType = optPetCare(intTypeCare).Caption
Select Case intTypeCare
Case 0
MsgBox .Food, OK, "Pet Care"
Case 1
MsgBox .Cleaner, OK, "Pet Care"
Case 2
MsgBox .Exercises, OK, "Pet Care"
Case 3
MsgBox .Attentions, OK, "Pet Care"
End Select
End With
Set PetCare = Nothing
End If
End Sub
Private Sub Form_Unload(Cancel As Integer)
Set frmPetCareClass = Nothing
End Sub
Private Function ValidatedInput() As Boolean
Dim blnValidated As Boolean
Dim obPetCare As OptionButton
If lstPetType.ListIndex < 0 Then
MsgBox _
"You must select a pet before continuing", _
OK, _
MessageTitle
lstPetType.SetFocus
blnValidated = False
GoTo ExitHere
Else
strPetType = lstPetType.Text
blnValidated = True
End If
For Each obPetCare In optPetCare
If obPetCare.Value = True Then
Set obPetCare = Nothing
GoTo ExitHere
End If
Next obPetCare
MsgBox _
"You must select a type of care for your " _
& strPetType & " before continuing", _
OK, _
MessageTitle
blnValidated = False
Set obPetCare = Nothing
GoTo ExitHere
ExitHere:
ValidatedInput = blnValidated
End Function
Private Sub optPetCare_Click(Index As Integer)
intTypeCare = Index
End Sub
Private Sub PetCare_PetCareAdvised(TypeCare As String)
lstPetType.ListIndex = -1
optPetCare(intTypeCare) = False
End Sub

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.
|