Hi everybody,

I am kind of new to vb.net and have some problems with images.

I need to show multiple images but the amount can be variable.
So I know there is some kind of picturebox in vb.net to show an image.
But how can I show multiple images without needing to add everytime a new picturebox.
Isn't there some picturebox list where I could create a list of images?

I am stuck at this stage, any help would be appreciated.
I googled like 2 houres for this problem without any succes.

Thank you very much

Another way is to create picturebox object programatically and add them into controls collection.

Add FlowLayoutPanel,

...
        FlowLayoutPanel1.AutoScroll = True
        FlowLayoutPanel1.FlowDirection = FlowDirection.TopDown
        For Each file As String In files
            Dim pic As New PictureBox
            pic.Image = Image.FromFile(file)
            FlowLayoutPanel1.Controls.Add(pic)
        Next
...

Hi ,

Try this code , this is only for 6 images. You can take more images too. If it works then let me know .

Thanks
Solution Expert

Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        Timer1.Start()
        
    End Sub


Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick

        Dim PicNumber, i As Integer
        PicNumber = New Random().Next(1, 6)

        For i = 1 To PicNumber
            If i = 1 Then
                PictureBox1.Image = Image.FromFile "C:\Images\\1.jpg")
            End If
            If i = 2 Then
                PictureBox1.Image = Image.FromFile("C:\Images\\2.jpg")
            End If
            If i = 3 Then
                PictureBox1.Image = Image.FromFile("C:\Images\\3.jpg")
            End If
            If i = 4 Then
                PictureBox1.Image = Image.FromFile("C:\Images\\4.jpg")
            End If
            If i = 5 Then
                PictureBox1.Image = Image.FromFile("C:\Images\\5.jpg")
            End If
            If i = 6 Then
                PictureBox1.Image = Image.FromFile("C:\Images\\6.jpg")
            End If
        Next
    End Sub
This article has been dead for over six months. Start a new discussion instead.