Click to See Complete Forum and Search --> : Runtime Error 340


lucbrunet
02-24-2005, 03:21 PM
Hi, I have a program where I am creating several controls at runtime using the control array method. So I have a Shape with it's index set to zero, and at the click of a button I create a new control with the load statement and it gets placed on the form with an index of 1 and so on. However, everytime I do this, when I unload the form I get this error:

Runtime Error 340: Control array element '1' doesn't exist

Do I have to manually unload all the created controls? Any ideas what this could mean?

mstraf
02-24-2005, 05:03 PM
Do you have some code in the Unload or QueryUnload events?
Marco

lucbrunet
02-25-2005, 09:13 AM
Nothing that has anything to to do with the newly created controls, should there be?

mstraf
02-25-2005, 02:40 PM
well, I was wondering if there was code that was causing the error. Do you get the problem in the IDE? Can you debug and trace where the error is?
Marco

lucbrunet
02-25-2005, 03:20 PM
Actually I found what the problem was. I was passing the controls to certain custom made classes, when the form was unloaded the controls would unload, and then the classes would unload. In the class I was also trying to unload the passed control (which was already unloaded from the form) and hence, my error.

Thanks!!