addimage trouble

Cableguy

Expert
Licensed User
Longtime User
Hi,
I'm tryingf to add an image in rumtime, but am getting sintax error...

here the line thath error out

addimage(control("panel"&NumbPanel+1),"icon",180,0,20,20)


"Panel"&NumbPanel is a runtime created panel

if i replace "Panel"&NumbPanel by panel2, wich i know is created, it works...
 

RandomCoder

Well-Known Member
Licensed User
Longtime User
I'd suggest placing MsgBox("panel"&NumbPanel+1) prior to your line that faults so that you can see which control is actually being used. It could be that you don't have the values you think you do.

Regards,
RandomCoder
 

Cableguy

Expert
Licensed User
Longtime User
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
 

RandomCoder

Well-Known Member
Licensed User
Longtime User
I could be way off the mark here but if NumbPanel hasn't beeb assigned a value then it is set to zero. Therefore NumbPanel+1 is equal to 1 not 2.
But you say that it works with the message box present but errors when its removed. That makes me think that its a timing issue?

Regards,
RandomCoder
 
Top