How to Make Slide Show in VB.Net

Submitted by: 
Visitors have accessed this post 737 times.

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.


Add new comment

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • You may insert videos with [video:URL]
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd> <table> <tr> <td> <th> <img> <h1> <h2> <h3> <iframe> [video]
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <asp>, <c>, <cpp>, <csharp>, <css>, <html4strict>, <java>, <javascript>, <mysql>, <php>, <python>, <sql>, <vb>, <vbnet>. The supported tag styles are: <foo>, [foo].
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.
CAPTCHA
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.