How to Create a Slideshow Program

How to Create a Slideshow Program thumbnail
Use VB.NET to create an image slideshow.

Knowing how to create a slide-show program using Microsoft Visual Basic.NET (VB.NET) can save you time when you need to show your pictures to friends and family. VB.NET is an object-oriented computer programming language used to design Windows applications. A slide show is used to display images while pausing a few seconds in between. In a few steps you will create a slide-show VB.NET project using a picture box, list box and a few buttons.

Things You'll Need

  • Microsoft Visual Basic Express
Show More

Instructions

    • 1

      Start Microsoft Visual Basic Express, click "New Project..." on the left pane of your screen, then select "Windows Forms Application." Click "OK."

    • 2

      Double click "Button" on the "Toolbox" pane to add a new button control. Add a second button. Double click "PictureBox" to add a new picture-box control.

    • 3

      Double click "ListBox" to add a list-box control. Double click "OpenFileDialog" to add the control to your project. Double click "Button1" to open the "Form1.vb"module.

    • 4

      Copy and paste the following code under "Button1_Click" to open the file dialog Window and browse for images:

      OpenFileDialog1.Multiselect = False

      OpenFileDialog1.Filter = "Jpeg|*.jpg|Gif|*.gif|Jpeg|*.jpeg|Bitmap|*.bmp"

      OpenFileDialog1.RestoreDirectory = True

      OpenFileDialog1.Title = "Browse"

      If OpenFileDialog1.ShowDialog <> DialogResult.Cancel Then

      ListBox1.Items.Add(OpenFileDialog1.FileName)

      End If

    • 5

      Copy and paste the following code to create a new procedure to loop through the images and pause between them using a Thread:

      Sub slideShow()

      Dim iCntr As Integer

      For iCntr = 0 To ListBox1.Items.Count - 1

      pctrBx.Image = Image.FromFile(ListBox1.Items.Item(iCntr))

      Thread.Sleep(3000)

      Next

      Exit Sub

      End Sub

    • 6

      Copy and paste the following code under "Public Class Form1" to declare two global variables:

      Dim pctrBx As New PictureBox

      Dim frmFrame As New Form

    • 7

      Click "Form1.vb" and double click "Button2." Copy and paste the following code to show the Form where the images are going to be displayed and also start the Thread:

      If ListBox1.Items.Count <> 0 Then

      frmFrame.Size = New Size(1000, 1000)

      frmFrame.BackColor = Color.Black

      frmFrame.Text = "Image Slideshow"

      pctrBx.Dock = DockStyle.Fill

      pctrBx.BackColor = Color.Black

      pctrBx.SizeMode = PictureBoxSizeMode.StretchImage

      pctrBx.BorderStyle = BorderStyle.Fixed3D

      frmFrame.Controls.Add(pctrBx)

      frmFrame.Show()

      Dim pauseThread As New Thread(AddressOf slideShow)

      pauseThread.Start()

      Else

      MsgBox("Please select an image")

      End If

    • 8

      Click "Form1.vb" and double click "ListBox1." Copy and paste the following code to add the selected item in the Listbox to the PictureBox control:

      PictureBox1.SizeMode = PictureBoxSizeMode.StretchImage

      PictureBox1.Image = Image.FromFile(ListBox1.SelectedItem)

    • 9

      Click the "Debug" menu then select "Start Debugging" to run your program. Click "Button1" to browse for images. Click "Button2" to start the slide show.

Related Searches:

References

  • Photo Credit frame for photo image by Sergey Galushko from Fotolia.com

Comments

You May Also Like

Related Ads

Featured