I tried to say that you can't. Your Sub assumes that the Calendar is always at the same position in the arrays of control names and this is not so if you use BringToFront.How can I use my sub with Calendar Control?
controls()=GetControls(contParent)
For i=0 To ArrayLen(controls())-1
controlsPos(i)=Control(controls(i)).Top
Next
controls()=GetControls(contParent)
For i=0 To ArrayLen(controls())-1
If controls(i) <> "" Then
controlsPos(i)=Control(controls(i)).Top
End If
Next
You could try checking that the control name is not an empty string. Don't assume that the position of a control in the array is always the same.
B4X:controls()=GetControls(contParent) For i=0 To ArrayLen(controls())-1 If controls(i) <> "" Then controlsPos(i)=Control(controls(i)).Top End If Next