How to Make Slide Show in VB.Net

In this tutorial, I will teach you how to make slide show in VB.Net. Slide show is a presentation of a series of pictures that is usually displayed in an electronic device like a projection screen to present clearly the text or images to an audience. Now, if you what to know how to make a program of it? It’s just simple if you only follow the steps that are shown below. So let’s start.

Creating Application

Step 1

Open Microsoft Visual Studio 2015 and create a new windows form application for vb. ps1.1

Step 2

Do the form just like this ps1.2

Step 3

Open the code view and declare an array variable for storing all images. After that, set an incrementing array variable.
  1. 'Set an Array of images
  2. Dim pics() As String = {"image1.jpg", "image2.jpg", "image3.jpg", "image4.jpg", "image5.jpg"}
  3.  
  4. 'Set this to use in incrementing an array index.
  5. Dim i As Integer = 0
Step 4 Go to the solution explorer, right click and add a folder named it “images”. After that, add pictures in it. ps1.3 Step 5 Double click the form and add the following codes to set a picture in the first load of the form.
  1. Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  2. 'Set the first image in the first load of the form.
  3. PictureBox1.Image = Image.FromFile("images/" + pics(0))
  4. End Sub
Step 6 Double click the timer and create a method for changing the pictures continuously.
  1. Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
  2. 'Set this formula to increment i by 1
  3. i += 1
  4.  
  5. 'Set a validation of pictures
  6. If pics.Length = i Then
  7. i = 0
  8. End If
  9.  
  10. 'Set to Load the image.
  11. PictureBox1.Image = Image.FromFile("images/" + pics(i))
  12. End Sub
Step 7 Double click the “btnNext” Toolstrip Button and add the following codes for the next picture.
  1. Private Sub ToolStripButton2_Click(sender As Object, e As EventArgs) Handles btnNext.Click
  2. 'Disable timer to prevent the next image from loading..
  3. Timer1.Enabled = False
  4.  
  5. 'Set this formula to increment i by 1
  6. i += 1
  7.  
  8. 'Set a validation of pictures
  9. If pics.Length = i Then
  10. i = 0
  11. End If
  12.  
  13. 'Set to Load the image.
  14. PictureBox1.Image = Image.FromFile("images/" + pics(i))
  15.  
  16. 'Re-Enable timer to resets the image loads in 5 seconds..
  17. Timer1.Enabled = True
  18. End Sub
Step 8 Double click the “btnPrevious” Toolstrip Button and add the following codes for the previous picture.
  1. Private Sub ToolStripButton2_Click(sender As Object, e As EventArgs) Handles btnNext.Click
  2. 'Disable timer to prevent the next image from loading..
  3. Timer1.Enabled = False
  4.  
  5. 'Set this formula to decrement i by 1
  6. i -= 1
  7.  
  8. 'Set a validation of pictures
  9. If pics.Length = i Then
  10. i = 0
  11. End If
  12.  
  13. 'Set to Load the image.
  14. PictureBox1.Image = Image.FromFile("images/" + pics(i))
  15.  
  16. 'Re-Enable timer to resets the image loads in 5 seconds..
  17. Timer1.Enabled = True
  18. End Sub
For any questions about this article. You can contact me @ Email – [email protected] Mobile No. – 09305235027 – TNT Or feel free to comment below.

Comments

Submitted byJohn M (not verified)on Wed, 01/08/2020 - 06:08

Hi Janobe. Thanks for your tutorial! Created the project in the way you describe it, but form load event causes an IO error - i.e file not found???

Add new comment