As I am sure you found out the =
operator is not defined for Image. There is a `.Equals method.
If PictureBox1.Image.Equals(Image.FromFile($"Picturebox{i}.jpg")) Then
I am using an interpolated string for the file name.
This will not solve your problem because the default implementation of equals means the 2 objects pointing to the same object in memory which is not the case. You can override the Equals
function to do a size and pixel by pixel comparison but there is probably a simpler way.
Keep track of what image is being displayed in a class level variable.
Private ImageNumber As Integer
Then increment ImageNumber each time the user clicks the NextImage button up to 8.
Private Sub NextImage_Click(sender As Object, e As EventArgs) Handles NextImage.Click
If ImageNumber = 8 Then
ImageNumber = 1
Else
ImageNumber += 1
End If
PictureBox1.Image = Image.FromFile($"Picturbox{ImageNumber}.jpg")
End Sub
Start the whole thing off in the Forms Load event.
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
PictureBox1.Image = Image.FromFile("Picturebox1.jpg")
ImageNumber = 1
End Sub