HI,
Thanks RandomCoder, Ialready thought of that, and I can't see the error...
The entire sub is as follows
Sub Button1_Click
'adds a first panel
addpanel(form1,"panel"&NumbPanel,50,50,150,100)
control("panel"&NumbPanel).color=csilver
'adds a panel within the previous panel
addpanel(form1,"panel"&NumbPanel+1,50,50,150,20)
control("panel"&NumbPanel+1).color=cblue
'necessary to bring the correct panel to front
control("panel"&NumbPanel).BringToFront
control("panel"&NumbPanel+1).BringToFront
'ads an image to the second panel
addimage(panel2,"icon",130,0,20,20)
control("icon").image="close.png"
control("icon").BringToFront
End Sub