VB 2005:  How to display a multiple number of pics in a picBox at an interval of 2 secs?

Posted on 2008-11-15
Last Modified: 2013-11-26
Dear Experts:

Hi again!

I would like to learn how to display a multiple number of pictures in a picbox at an interval of
2-3 seconds with fadein and fadeout effects.

Thanks a lot!
Question by:duta
    LVL 14

    Expert Comment

    To just switch the images you would have to set up a timer that would programmatically update the image.   The fading in and out may be a lot more difficult as I don't think that those properties are built in.  The only thing I can think of would be able to change the opacity of the control if that is even possible.  Not sure that is available for that control.   Maybe some one else will know of a better solution, those are just my initial thoughts.

    Author Comment

    Can you kindly give me the code to implement your tip?

    Thanks a lot!
    LVL 14

    Accepted Solution

    Here is a link to show how to possibly do the fade in and out.

    I have attached sample code for the timer functionality to just swap the images without a fade:
    Public Class Form1
        Dim Timer1 As New Timer()
        Dim imagePath As String = "C:\Documents and Settings\user\My Documents\My Pictures\"
        Dim Images() As String = New String() {"Picture1.gif", "picture2.gif"}
        Dim index As Integer = 0
        Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
        End Sub
        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            Timer1.Interval = 3000
            AddHandler Timer1.Tick, AddressOf Timer_Tick
        End Sub
        Private Sub Timer_Tick(ByVal sender As Object, ByVal e As System.EventArgs)
            If index > Images.Length - 1 Then
                index = 0
            End If
            pb.Image = Image.FromFile(imagePath & Images(index))
            index += 1
        End Sub
    End Class

    Open in new window


    Author Comment

    Thank you so much for your kind tips.

    By the way, I would like to put all the images in the Resource folders so that I don't have to change
    the paths when I open the project at other platforms or workstations.

    Thanks a lot!

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
    Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now