Auto Image Slide : Visual Basic Programming

The sample demonstrates how to display image slideshow in a Windows Forms application

Controls Used :

PictureBox Control

The Windows Forms PictureBox control is used to display images in bitmap, GIF,icon, or JPEG formats.

You can set the Image property to the Image you want to display, either at design time or at run time. You can pro-grammatically change the image displayed in a picture box, which is particularly useful when you use a single form to display different pieces of information.



Source Code :

Public Class Form1
    Private r As New Random()
    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load

    End Sub

    Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
        Dim i As Integer = +1

        PictureBox1.Image = My.Resources.ResourceManager.GetObject("Image" & r.Next(i, 8))



    End Sub

    Private Sub OnButton_Click(sender As Object, e As EventArgs) Handles OnButton.Click
        Timer1.Start()

    End Sub



    Private Sub Speed_SelectedIndexChanged(sender As Object, e As EventArgs) Handles Speed.SelectedIndexChanged
        If Speed.Text = "Slow" Then
            Timer1.Interval = 2000
            '2 secs
        ElseIf Speed.Text = "Medium" Then
            Timer1.Interval = 1000
            '1 Sec
        ElseIf Speed.Text = "Fast" Then
            Timer1.Interval = 500
            '1/2 sec

        End If
    End Sub

    Private Sub OffButton_Click(sender As Object, e As EventArgs) Handles OffButton.Click
        Timer1.Stop()

    End Sub
End Class



Comments

Popular Posts