home *** CD-ROM | disk | FTP | other *** search
/ ActiveX Programming Unleashed CD / AXU.iso / activex / demos / oletrial / samples / vb / mhminp / cec_mon.cls < prev    next >
Encoding:
Text File  |  1995-11-30  |  2.9 KB  |  93 lines

  1. VERSION 1.0 CLASS
  2. BEGIN
  3.   MultiUse = -1  'True
  4. END
  5. Attribute VB_Name = "CEntryControlMonitor"
  6. Attribute VB_Creatable = False
  7. Attribute VB_Exposed = False
  8. ' This class monitors the input controls in its private collection so that when
  9. '   all of the unput controls have been filled the m_ButtonToBeEnabled is enabled
  10. '   otherwise it is kept disabled
  11. Option Explicit
  12.  
  13. Private m_colEntryControls As Collection
  14. Private m_ButtonToBeEnabled As CommandButton
  15. Private Sub Class_Initialize()
  16.  
  17.  
  18.     ' intialize private data
  19.     Set m_colEntryControls = New Collection
  20.     
  21.     
  22. End Sub
  23. ' This procedure adds the passed input control to the private collection.  The
  24. '   iMinimumAllowableText parameter specifies the number of characters
  25. '   which must be entered in the control for it to be considered not empty
  26. Public Sub Add(oYourControl As MhMaskInput, iMinimumAllowableText As Integer)
  27.  
  28.  
  29.     Dim oTempEntryControl As New CEntryControl
  30.     
  31.     With oTempEntryControl
  32.         Set .InputControl = oYourControl
  33.         .MinimumCharactersAllowed = iMinimumAllowableText
  34.         .HasMinimumCharacters = False
  35.         ' add this object to the collection
  36.         m_colEntryControls.Add oTempEntryControl, oYourControl.Name
  37.     End With ' oTempEntryControl
  38.     
  39.  
  40. End Sub
  41. Public Sub VerifyEntryControl(oYourControl As MhMaskInput)
  42.  
  43.  
  44.     Static bButtonEnabled As Boolean
  45.     Dim bUnfilledControlFound As Boolean
  46.     Dim oTempEntryControl As New CEntryControl
  47.     
  48.     ' locate the control
  49.     Set oTempEntryControl = m_colEntryControls.Item(oYourControl.Name)
  50.     
  51.     ' if this control has the minimum number of characters required to
  52.     '   consider the control not empty then check the other controls also
  53.     If Len(Trim$(oTempEntryControl.InputControl.Text)) >= oTempEntryControl.MinimumCharactersAllowed Then
  54.         oTempEntryControl.HasMinimumCharacters = True
  55.         ' if there are no controls which have HasMinimumCharacters=False then enabled the button
  56.         For Each oTempEntryControl In m_colEntryControls
  57.             If Not oTempEntryControl.HasMinimumCharacters Then
  58.                 bUnfilledControlFound = True
  59.                 Exit For
  60.             End If
  61.         Next oTempEntryControl
  62.         If Not bUnfilledControlFound Then
  63.             m_ButtonToBeEnabled.Enabled = True
  64.             bButtonEnabled = True
  65.         End If
  66.     Else
  67.         ' otherwise disable the m_ButtonToBeEnabled if it has not
  68.         '   already been disabled
  69.         If bButtonEnabled Then
  70.             m_ButtonToBeEnabled.Enabled = False
  71.             bButtonEnabled = False
  72.         End If
  73.     End If
  74.     
  75.  
  76. End Sub
  77. Public Property Set ButtonToBeEnabled(vNewButton As CommandButton)
  78.  
  79.  
  80.     Set m_ButtonToBeEnabled = vNewButton
  81.     
  82.      
  83. End Property
  84. Private Sub Class_Terminate()
  85.  
  86.  
  87.     ' clear private data
  88.     Set m_colEntryControls = Nothing
  89.     Set m_ButtonToBeEnabled = Nothing
  90.  
  91.  
  92. End Sub
  93.