Forum > Beginners

Coponents and names(Solved)

(1/2) > >>

I have 52 card images labeled I1...I52; I can always find the string value 'I1'..'I52'.
But I would like the Timage name I1..I52. My code at line 8 isn't right. I need to pass it as a parm in the procedure ShowTrash.

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure TForm1.MoveToTrash(S : integer); Var  ImageName : TImage;  MyImageName : string; begin  Inc(GTRASHBIN);  MyImageName:='I'+IntToStr(S);  ImageName := TImage.FindComponent(MyImageName);   // Error  ShowTrash( GTRASHBIN,ImageName ); end;  

ImageName := TImage(FindComponent(MyImageName));

Perfect! Thanks

Your welcome

Question/Test for JLWest

Can you explain why it works; and why your code did not?

I Know this is odd thing to post; but I think a good learning question; rather than just fixing code..


 ImageName := TImage.FindComponent(MyImageName);

ImageName := TImage(FindComponent(MyImageName));

I can see the difference but don't understand.


[0] Message Index

[#] Next page

Go to full version