[Gambas-user] Question about how to address more than 1 checkbox or picturebox item in for-next loop

Ron Klinkien ron at ...1740...
Thu Jul 26 16:20:34 CEST 2007


Hi all,

Say i have defined more than one checkbox or picturebox item in the gui 
designer and i want to change the status of them in a
for-next loop, instead of if-end if them one after the other, if and how 
is this possible?

I have defined PictureBoxI0 - PictureBoxI7
----------------------------
 DIM i AS Integer
 DIM SensorByte1 as Byte
 DIM PBoxI AS PictureBox = [PictureBoxI0, PictureBoxI1, PictureBoxI2, 
PictureBoxI3, PictureBoxI4, PictureBoxI5, PictureBoxI6, PictureBoxI7]
       
    FOR i = 0 TO 7
     IF BTst(SensorByte1, i) THEN
           PBoxI[i].Picture = picOn.Picture
      ELSE
           PBoxI[i].Picture = picOff.Picture
      END IF
    NEXT
----------------------------
Doesn't work.
Error is
Type Mismatch:  Wanted PictureBox got Object[] instead.

I have now:

    IF BTst(SensorByte1, 7) THEN
      PictureBoxI7.Picture = picOn.Picture
    ELSE
      PictureBoxI7.Picture = picOff.Picture
    END IF

    IF BTst(SensorByte1, 6) THEN
      PictureBoxI6.Picture = picOn.Picture
    ELSE

and so on... not so nice if you have more than 24 of them...

Thanks in advance for any pointers...

Regards,
Ron.






More information about the User mailing list