Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 211
  • Last Modified:

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

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!
0
duta
Asked:
duta
  • 2
  • 2
1 Solution
 
jjardineCommented:
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.
0
 
dutaAuthor Commented:
Can you kindly give me the code to implement your tip?

Thanks a lot!
0
 
jjardineCommented:
Here is a link to show how to possibly do the fade in and out.   http://social.msdn.microsoft.com/forums/en-US/vbgeneral/thread/477830bb-f3f2-4d19-90b7-f81599de7f7d/

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
        Timer1.Stop()
    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
        Timer1.Start()
    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

0
 
dutaAuthor Commented:
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!
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now