For loop with Images...

Hi all !

My problem is I use a For loop for multiply Images but Image Controls don't display my images.

This is my loop :
B4X:
For i = 1 To 46
   If i = 1 Then
      AddImage("Form3","Kana1",0,0,30,30,"cStretchImage","kana/h_ka.png",220,220,220,True,True)
   Else
      AddImage("Form3","Kana" & i,(i-1)*30,(i-1)*30+5,30,30,"cStretchImage","kana/h_" & Kana(i) & ".png",220,220,220,True,True)
   End If
Next

Please help me...
 
I've found if I do it the first Image Control display my image correctly, but I can't repeat this lines in the loop...
B4X:
For i = 1 To 46
   If i = 1 Then
      AddImage("Form3","Kana1",0,0,30,30,"cStretchImage","kana/h_ka.png",220,220,220,True,True)
   Else
      AddImage("Form3","Kana" & i,(i-1)*30,(i-1)*30+5,30,30,"cStretchImage","kana/h_" & Kana(i) & ".png",220,220,220,True,True)
   End If
Next
Kana1.Mode = cStretchImage
Kana1.Image = "kana/h_ka.png"
 

mjcoon

Well-Known Member
Licensed User
Not sure why the i=1 case has to be distinct...

But is the problem as simple as using Unix-like "/" for the folder separator character instead of M$ "\" in "kana/h_ka.png"?

Mike.
 
I'd find the solution :
B4X:
For i = 1 To 46
   If i = 1 Then
      AddImage("Form3","Kana1",0,0,30,30)
   Else
      AddImage("Form3","Kana" & i,(i-1)*30,(i-1)*30+5,30,30)
   End If
Next
For i = 1 To 46
   Control("Kana" & i).Image = "kana/h_" & Kana(i) & ".png"
   Control("Kana" & i).Mode = cStretchImage
Next
 
Top