[Gambas-user] Child control Index - Question.

Ian Roper westozscribe at gmail.com
Wed Feb 8 00:25:37 CET 2023


Hi ,

I'm trying to track down a strange error: [Bad Index] when cycling 
through child controls of a container.

I have a process that resets an input form prior to allowing new input ( 
adding a new record)

A simplified version of the routine is below.

   For Each ControlElement In InControl.Children

  If ControlElement Is TextBox Then Object.SetProperty(ControlElement, 
"Background", Color.White)
     If ControlElement Is TextBox Then 
Object.SetProperty(ControlElement, "Text", EmptyString) '<-----------<<< 
Error occurs here.
     If ControlElement Is TextArea Then 
Object.SetProperty(ControlElement, "Text", EmptyString)
     If ControlElement Is TextEditor Then 
Object.SetProperty(ControlElement, "Text", EmptyString)
     If ControlElement Is ValueBox Then 
Object.SetProperty(ControlElement, "Value", Null)
     If ControlElement Is CheckBox Then 
Object.SetProperty(ControlElement, "Value", 0)

Next

I used this same process on 40+ forms and there is only one form that 
causes an error.

Many forms have multiple TextBox controls.

I have deleted and recreated the control on the form - same error.

The input container is a standard Panel.

If I comment out the one line that causes the error, then everything 
works as required.


What does the  bad '*Index*' refer to ? I am assuming it is the 'Symbol' 
column of the attached image.

Cheers,

Ian.





-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20230208/7b0f00c6/attachment-0001.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: BadIndexError.png
Type: image/png
Size: 35533 bytes
Desc: not available
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20230208/7b0f00c6/attachment-0001.png>


More information about the User mailing list