Hey I need some help to program a little begginner project. So I want to create a program that displays an image when you press the start button. When you press the "Next button" it will display a new image.

My problem is, I want the image to change EVERY time you hit the next button.

Here is my basic program:

http://i834.photobucket.com/albums/zz266/rugbykid92/program.png

Here is my code that I have so far, I know it won't work though :)

http://i834.photobucket.com/albums/zz266/rugbykid92/code1.png

Please, I only started today so simple techniques please :D
I appreciate your help in advance.

...I only started today so simple techniques...

I think it was more difficult to try and come up with a easy to understand solution than to put the code together.:D

1 PictureBox, 3 Buttons(Button2 is not used, but looks good:D)

Public Class Form1
    Private myCoolImagesFullPaths As New ArrayList '// Store full path of images in, just like using a ListBox.
    Private mySelectedCoolImageIndex As Integer = 0 '// determines where the index is in your ArrayList.

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Button1.Text = "Previous" : Button2.Text = "Start" : Button3.Text = "Next"
        '// Add Full Path of images to your ArrayList.
        myCoolImagesFullPaths.Add("C:\test1.png")
        myCoolImagesFullPaths.Add("C:\test2.png")
        myCoolImagesFullPaths.Add("C:\test3.png")
        myCoolImagesFullPaths.Add("C:\test4.png")
        myCoolImagesFullPaths.Add("C:\test5.png")
        '// Load first image in PictureBox.
        PictureBox1.Image = Image.FromFile(myCoolImagesFullPaths(mySelectedCoolImageIndex).ToString)
        '//--- myCoolImagesFullPaths(0)= image 1, myCoolImagesFullPaths(1) = image 2, myCoolImagesFullPaths(2) = image 3, etc.
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        If Not mySelectedCoolImageIndex = 0 Then '// check if Not at 0.
            mySelectedCoolImageIndex -= 1 '// subtract -1.
            '// add new image from ArrayList.
            PictureBox1.Image = Image.FromFile(myCoolImagesFullPaths(mySelectedCoolImageIndex).ToString) '// load image.
        Else '// if at 0, notify user.
            MsgBox("First Image.", MsgBoxStyle.Information)
        End If
    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        '// check if Not the index equals the total images.Count -1. -1 since Index based and starts at 0 not 1.
        If Not mySelectedCoolImageIndex = myCoolImagesFullPaths.Count - 1 Then
            mySelectedCoolImageIndex += 1 '// add + 1 to your Index number.
            PictureBox1.Image = Image.FromFile(myCoolImagesFullPaths(mySelectedCoolImageIndex).ToString) '// load image.
        Else '// if at last image in ArrayList, notify user.
            MsgBox("Last Image.", MsgBoxStyle.Information)
        End If
    End Sub
End Class

Next time, please use the (CODE) option on the Message toolbar and add your code.

Very sorry about not using the CODE option, I must have overlooked it.

The code does exactly what I was looking for and the explanations make perfect sense.

MANY THANKS!!!

Glad I could help.:)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.