SETP
asked on
Unload Error
I have an array of a couple of sliders and checkboxes on a VB6 form. I created them dynamically (programatically) using this code:
For i = 1 to 10
Load Slider1 (i)
Load CheckBox1 (i)
Next i
The problem comes in when I try to unload the controls. I start from the highest indexed one (10) and make my way down:
For i = Slider1.UBound To 1 Step -1
Unload Slider1 (i)
Unload CheckBox1 (i)
Next i
As soon as it executes the first loop, I get this error message:
Run-time Error '365':
Unable to unload within this context.
Any ideas?
For i = 1 to 10
Load Slider1 (i)
Load CheckBox1 (i)
Next i
The problem comes in when I try to unload the controls. I start from the highest indexed one (10) and make my way down:
For i = Slider1.UBound To 1 Step -1
Unload Slider1 (i)
Unload CheckBox1 (i)
Next i
As soon as it executes the first loop, I get this error message:
Run-time Error '365':
Unable to unload within this context.
Any ideas?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
WOW!!! Apparently you cannot unload controls from the Change, Click, or DropDown events of a ComboBox! What the hell??? Why on earth not??? Here is the full list if events you cannot unload controls from:
the Paint event for the form or for a control on the form that has the Paint event.
the Change, Click, or DropDown events of a ComboBox.
the Scroll event of an HScrollBar or VScrollBar control.
the Resize event of a Data, Form, MDIForm, or PictureBox control.
the Resize event of an MDIForm that is trying to unload an MDI child form.
the RePosition or Validate event of a Data control.
the ObjectMove event of an OLE Container control.
(http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vb98/html/vbmsgldCantUnloadHere.asp)
There's also a thread on Experts-Exchange from someone who had the same problem but noone could explain to him why Microsoft put these restrictions in Visual Basic 6.
Thanks for you help TimCottee
the Paint event for the form or for a control on the form that has the Paint event.
the Change, Click, or DropDown events of a ComboBox.
the Scroll event of an HScrollBar or VScrollBar control.
the Resize event of a Data, Form, MDIForm, or PictureBox control.
the Resize event of an MDIForm that is trying to unload an MDI child form.
the RePosition or Validate event of a Data control.
the ObjectMove event of an OLE Container control.
(http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vb98/html/vbmsgldCantUnloadHere.asp)
There's also a thread on Experts-Exchange from someone who had the same problem but noone could explain to him why Microsoft put these restrictions in Visual Basic 6.
Thanks for you help TimCottee
ASKER