VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
END
Attribute VB_Name = "CEntryControlMonitor"
Attribute VB_Creatable = False
Attribute VB_Exposed = False
' This class monitors the input controls in its private collection so that when
'   all of the unput controls have been filled the m_ButtonToBeEnabled is enabled
'   otherwise it is kept disabled
Option Explicit

Private m_colEntryControls As Collection
Private m_ButtonToBeEnabled As CommandButton
Private Sub Class_Initialize()


    ' intialize private data
    Set m_colEntryControls = New Collection
    
    
End Sub
' This procedure adds the passed input control to the private collection.  The
'   iMinimumAllowableText parameter specifies the number of characters
'   which must be entered in the control for it to be considered not empty
Public Sub Add(oYourControl As MhMaskInput, iMinimumAllowableText As Integer)


    Dim oTempEntryControl As New CEntryControl
    
    With oTempEntryControl
        Set .InputControl = oYourControl
        .MinimumCharactersAllowed = iMinimumAllowableText
        .HasMinimumCharacters = False
        ' add this object to the collection
        m_colEntryControls.Add oTempEntryControl, oYourControl.Name
    End With ' oTempEntryControl
    

End Sub
Public Sub VerifyEntryControl(oYourControl As MhMaskInput)


    Static bButtonEnabled As Boolean
    Dim bUnfilledControlFound As Boolean
    Dim oTempEntryControl As New CEntryControl
    
    ' locate the control
    Set oTempEntryControl = m_colEntryControls.Item(oYourControl.Name)
    
    ' if this control has the minimum number of characters required to
    '   consider the control not empty then check the other controls also
    If Len(Trim$(oTempEntryControl.InputControl.Text)) >= oTempEntryControl.MinimumCharactersAllowed Then
        oTempEntryControl.HasMinimumCharacters = True
        ' if there are no controls which have HasMinimumCharacters=False then enabled the button
        For Each oTempEntryControl In m_colEntryControls
            If Not oTempEntryControl.HasMinimumCharacters Then
                bUnfilledControlFound = True
                Exit For
            End If
        Next oTempEntryControl
        If Not bUnfilledControlFound Then
            m_ButtonToBeEnabled.Enabled = True
            bButtonEnabled = True
        End If
    Else
        ' otherwise disable the m_ButtonToBeEnabled if it has not
        '   already been disabled
        If bButtonEnabled Then
            m_ButtonToBeEnabled.Enabled = False
            bButtonEnabled = False
        End If
    End If
    

End Sub
Public Property Set ButtonToBeEnabled(vNewButton As CommandButton)


    Set m_ButtonToBeEnabled = vNewButton
    
     
End Property
Private Sub Class_Terminate()


    ' clear private data
    Set m_colEntryControls = Nothing
    Set m_ButtonToBeEnabled = Nothing


End Sub
