What is wrong with this code? All I want to do is display photos for a slide show, with about 5 seconds pause between photos. It will only show the last photo. The photo directory and file names are contained in the ComboBox.

(I thought I posted this wrong, so I did it again. This is my first post here. )

Private Sub cmdSlideShow_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdSlideShow.Click

Dim x As Integer
With ComboBox1
For x = 0 To (.Items.Count) - 1
labFile.Text = .Items(x).ToString
PictureBox1.ImageLocation = .Items(x).ToString
Threading.Thread.Sleep(TimeSpan.FromSeconds(5).TotalMilliseconds)
Next
End With

End Sub

Here you are:

Private Sub cmdSlideShow_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdSlideShow.Click

  Dim x As Integer
  With ComboBox1
    For x = 0 To (.Items.Count) - 1
      labFile.Text = .Items(x).ToString
      PictureBox1.Image = Image.FromFile(.Items(x).ToString)
      My.Application.DoEvents()
      Threading.Thread.Sleep(CInt(TimeSpan.FromSeconds(5).TotalMilliseconds))
    Next x
  End With

End Sub

For some reason PictureBox1.ImageLocation = .Items(x).ToString didn't work. Instead I had to use Image.FromFile() to get images displayed. Also simple PictureBox1.Refresh() was not enough. It did redraw the image but My.Application.DoEvents() was needed to update label's text.

Thank you SO very much! I tried some of the lines of code you added, but didn't have the DoEvents. Thanks again! ~ Sheryl

This question has already been answered. Start a new discussion instead.