So I have a form with a variety of controls, all added at design time. Some of the controls in this page I want to disable (as a group) when the form is busy performing a task so the user cannot interefere.
To this end, I created a collection object that the relevant controls are added to. They controls are added to this collection in form_load. (If there were any dynamic controls, I'd add them to this collection as they were created too).
However I started getting intermittent runtime errors, with the objects not being found in their own control array (they are still loaded, as you can see and interact with them on the form). Form_load is visible below
Private Sub Form_Load()
Dim Item As Variant
SelectScanCombo.Enabled = False
LowResolutionTextBox(0).Text = Target_LO_Res
HighResolutionTextBox(0).Text = Hi_Res_Resolution
Set InterfaceObjects = New Collection
InterfaceObjects.Add GoButton
InterfaceObjects.Add FilePathBox
InterfaceObjects.Add HighResEnabled
For Each Item In LowResolutionTextBox
InterfaceObjects.Add Item
Next Item
For Each Item In HighResolutionTextBox
InterfaceObjects.Add Item
Next Item
For Each Item In ResolutionModeSelect
InterfaceObjects.Add Item
Next Item
RunInProgress = False
End Sub
InterfaceObjects is a private member of the form. Adding a watch to break on change of LowResolutionTextBox(0) breaks (on some form loads, not all) at the line `InterfaceObjects.Add GoButton
Is there something odd happening when I create a new collection instance for interfaceobjects? Why? What is causing (or even could cause) controls to go missing from their original control array without being erased?
(This all happens when running in the IDE. Not tested with the compliled version)