Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27212

How to write this shorter?

$
0
0
hey guys,
I have a question.
im trying to make 25 pictureboxes the same picture. i have it written like this now:

Code:

PictureBox1.Image = ImageList1.Images.Item(0)
        PictureBox2.Image = ImageList1.Images.Item(0)
        PictureBox3.Image = ImageList1.Images.Item(0)
        PictureBox4.Image = ImageList1.Images.Item(0)
        PictureBox5.Image = ImageList1.Images.Item(0)
        PictureBox6.Image = ImageList1.Images.Item(0)
        PictureBox7.Image = ImageList1.Images.Item(0)
        PictureBox8.Image = ImageList1.Images.Item(0)
        PictureBox9.Image = ImageList1.Images.Item(0)
        PictureBox10.Image = ImageList1.Images.Item(0)
        PictureBox11.Image = ImageList1.Images.Item(0)
        PictureBox12.Image = ImageList1.Images.Item(0)
        PictureBox13.Image = ImageList1.Images.Item(0)
        PictureBox14.Image = ImageList1.Images.Item(0)
        PictureBox15.Image = ImageList1.Images.Item(0)
        PictureBox16.Image = ImageList1.Images.Item(0)
        PictureBox17.Image = ImageList1.Images.Item(0)
        PictureBox18.Image = ImageList1.Images.Item(0)
        PictureBox19.Image = ImageList1.Images.Item(0)
        PictureBox20.Image = ImageList1.Images.Item(0)
        PictureBox21.Image = ImageList1.Images.Item(0)
        PictureBox22.Image = ImageList1.Images.Item(0)
        PictureBox23.Image = ImageList1.Images.Item(0)
        PictureBox24.Image = ImageList1.Images.Item(0)
        PictureBox25.Image = ImageList1.Images.Item(0)

Is there some way how I can write this shorter? I was thinking about making a variable and then use it like this:

Code:

Dim x as double

picturebox(x).image = ImageList1.Images.Item(0)

x = x + 1

Well... this doesn't work ofcourse

Thanks!

Scrowmetal

Viewing all articles
Browse latest Browse all 27212

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>