Basic Slideshow question
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: Basic Slideshow question

  1. #1
    Join Date
    Dec 2002
    Location
    Tenby, Wales
    Posts
    277

    Basic Slideshow question

    Hi people

    I am creating basic slideshow form to finish off an app I am writing. I have been at it all day finishing off the main app and am getting very tired now!!

    Anyway, I have a form (which is called by another form) with just a Picturebox and a Timer on it. I use the following code to read in all the images in a folder:
    Code:
    Public Function GetPics()
            Dim pic() As String = Directory.GetFiles(strPicSource)
    
            For i As Integer = 0 To UBound(pic)
                picPath = pic(i)
                'MsgBox(pic(i))
            Next
    
        End Function
    I want to be able to display them in the Picturebox on the same form at an interval of around 1 every 5 seconds. I have thought about using a Timer and using the Timer1_tick event to trigger the picture change but how can I go about this? I cannot have the following:
    Code:
     Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
            'PictureBox1.ImageLocation = pic()
        End Sub
    As this just points to the array of images and not a single image and there is no way of telling it to move to the next image each time.

    Can anyone help me out here?

    Thanks in advance
    Visual Basic 2005 ver. 8.0.50727.867

  2. #2
    Join Date
    Feb 2009
    Posts
    1

    Re: Basic Slideshow question

    try this:

    Code:
    Public Function GetPics()
            Public pic() As String = Directory.GetFiles(strPicSource)
            Public picturecount as integer = 0
            timer1.start
    
        End Function
    tick function:

    Code:
    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
            if picturecount <> ubound(pic)
                picPath = pic(picturecount)
                PictureBox1.ImageLocation = picPath
                picturecount = picturecount + 1
            end if
        End Sub
    This is just off the top of my head though - and this does sound like homework to me . . .

    Also you should be able to manipulate it to not use public variables - it's late and i've not had much sleep

  3. #3
    Join Date
    Dec 2002
    Location
    Tenby, Wales
    Posts
    277

    Re: Basic Slideshow question

    Cheers for the reply. Believe me, if this if Homework as you suggest then I must be the oldest student in Britain at 31!!

    I was just very tired just like yourself after a 10hr shift then coming home to this project. Check my other posts to see other projects I have written. You'll know I'm not a Student then!

    Will check out your code this morning.

    Thanks again
    Last edited by brjames32; February 26th, 2009 at 01:59 AM.
    Visual Basic 2005 ver. 8.0.50727.867

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center