Quantcast
Channel: VBForums
Viewing all articles
Browse latest Browse all 15621

VS 2019 Restarting Image Loop

$
0
0
Hi, So I'm doing a project for school and I have an image loop for my program with the code as follows
Code:

    Dim Images(10) As Bitmap
    Dim Pos As Integer = 0
    Private Sub MainMenu_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        'Inserting images from resources
        Images(0) = GloriousGetaways.My.Resources.MM10
        Images(1) = GloriousGetaways.My.Resources.MM1
        Images(2) = GloriousGetaways.My.Resources.MM2
        Images(3) = GloriousGetaways.My.Resources.MM3
        Images(4) = GloriousGetaways.My.Resources.MM4
        Images(5) = GloriousGetaways.My.Resources.MM5
        Images(6) = GloriousGetaways.My.Resources.MM6
        Images(7) = GloriousGetaways.My.Resources.MM7
        Images(8) = GloriousGetaways.My.Resources.MM8
        Images(9) = GloriousGetaways.My.Resources.MM9

        'Puts the images into order
        PictureBox1.Image = Images(Pos)
    End Sub

    Private Sub MainmenuSlideshowTimer_Tick(sender As Object, e As EventArgs) Handles MainmenuSlideshowTimer.Tick
        'Starting the timer for the slideshow on main menu
        MainmenuSlideshowTimer.Start()
        'Setting the time between slides to 5 seconds
        MainmenuSlideshowTimer.Interval = 5000
        Pos = Pos + 1

            If Pos < Images.Length - 1 Then

                PictureBox1.Image = Images(Pos)
            Else
                Pos = Images.Length - 2
            End If
    End Sub

It works perfectly but the slideshow stops once it gets to the last image on the form. How would I make it so it continuously loops and restarts the slideshow from the first image once it gets to the last image. I'm not very advanced so I'm unsure.

Have a good day :)

Viewing all articles
Browse latest Browse all 15621

Trending Articles



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