11 Replies - 56348 Views - Last Post: 28 November 2011 - 04:58 AM Rate Topic: ***-- 2 Votes

#1 Kipper  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 03-October 07

Image slideshow using picture box and timer

Post icon  Posted 03 October 2007 - 01:46 PM

Hi All!!
I need to design the presentation in vb.net using picture box and timer.

Need to display the images on regular time basis.

Can anybody help me on this?
Is This A Good Question/Topic? 0
  • +

Replies To: Image slideshow using picture box and timer

#2 Martyr2  Icon User is offline

  • Programming Theoretician
  • member icon

Reputation: 4312
  • View blog
  • Posts: 12,090
  • Joined: 18-April 07

Re: Image slideshow using picture box and timer

Posted 03 October 2007 - 02:44 PM

Usually we ask to see some code first before we can help. Only then can we fully understand what you are trying to do. However, I think I can give you some advice how to do this.

Create a new project in VB.NET and put a picturebox and a timer control on the form. Double click your timer to open up its Tick event. In there you can simply set the picturebox image. So investigate the timer control and its tick event and how that works, then the picturebox and its "image" property to load images to.

"And that is half the battle!" GI JOEEEEEE :)
Was This Post Helpful? 1
  • +
  • -

#3 Guest_kok loong*


Reputation:

Re: Image slideshow using picture box and timer

Posted 28 March 2010 - 07:18 PM

Martyr, currently my slideshow timer was set in the coding, if i want to set the slideshow each images with different timer on the form UI, what should i do for this case?
Was This Post Helpful? 0

#4 _HAWK_  Icon User is offline

  • Master(Of Foo)
  • member icon

Reputation: 1043
  • View blog
  • Posts: 4,057
  • Joined: 02-July 08

Re: Image slideshow using picture box and timer

Posted 28 March 2010 - 08:31 PM

That depends, which Timer are you using? System.Timers.Timer or the Windows.Forms.Timer. The reason I ask is the first one runs on a separate thread as far as the timer_elapsed event - this route would require you having a delegate to set the images as the picturebox control is on a different thread (UI thread) and must be invoked. Also there is no real difference b/t a control set in code vs the control dropped from the toolbox, except the runtime control will need an Addhandler to the Tick or Elapsed event.
Was This Post Helpful? 0
  • +
  • -

#5 Luc001  Icon User is offline

  • D.I.C Addict

Reputation: 84
  • View blog
  • Posts: 617
  • Joined: 04-May 09

Re: Image slideshow using picture box and timer

Posted 29 March 2010 - 01:45 AM

View Postkok loong, on 29 March 2010 - 02:18 AM, said:

Martyr, currently my slideshow timer was set in the coding, if i want to set the slideshow each images with different timer on the form UI, what should i do for this case?


Hi,

I think you meant that you set the timers interval in the coding.
What you can do is to set the timers interval randomly. That means that each image will be showing in the slideshow with a time difference.

Just a thought.
Was This Post Helpful? 0
  • +
  • -

#6 kokloong  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 25-February 10

Re: Image slideshow using picture box and timer

Posted 01 April 2010 - 06:47 PM

Luc001, can you show me how to do like what you mention? I need help on this matter as well..
Was This Post Helpful? 0
  • +
  • -

#7 Luc001  Icon User is offline

  • D.I.C Addict

Reputation: 84
  • View blog
  • Posts: 617
  • Joined: 04-May 09

Re: Image slideshow using picture box and timer

Posted 02 April 2010 - 02:12 AM

Hi,

Here's an example how I did it.
You'll need a Picturebox named pbNewImage, a Timer and a Button named btnView.
Try this peace of code.

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
' create a number between a certain value and becomes the interval
        Dim max As Integer = 5000
        Dim rnd As New Random
        Dim rand As Integer = rnd.Next(10, max + 1)
        Dim i As Integer = 1
        Dim number(max - 1) As Integer

        For i = 0 To max - 1
            If number(i) = rand Then
                rand = rnd.Next(1, max + 1)
                i = -1
            ElseIf number(i) = 0 Then
                number(i) = rand
                rand = rnd.Next(1, max + 1)
                If i = max - 1 Then
                    Exit For
                End If
                i = -1
            End If
        Next
        Timer1.Interval = number(i)
        i += 1

        ChangeImage()
    End Sub

    Private Sub ChangeImage()

        Static Dim iImage1 As Integer

        Select Case iImage1
            Case 0

                pbNewImage.Visible = True
                pbNewImage.Image = My.Resources.imagename
                iImage1 += 1
            Case 1

                pbNewImage.Visible = True
                pbNewImage.Image = My.Resources.imagename
                iImage1 += 1
            Case 2

                pbNewImage.Visible = True
                pbNewImage.Image = My.Resources.imagename
                iImage1 += 1
            Case 3

                pbNewImage.Visible = True
                pbNewImage.Image = My.Resources.imagename
                iImage1 += 1
            Case 4

                pbNewImage.Visible = True
                pbNewImage.Image = My.Resources.imagename
                iImage1 = 0

        End Select
    End Sub
   
    Private Sub btnView_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnView.Click
        Timer1.Start()
    End Sub

Was This Post Helpful? 1
  • +
  • -

#8 kokloong  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 25-February 10

Re: Image slideshow using picture box and timer

Posted 07 April 2010 - 07:55 PM

"pbNewImage.Image = My.Resources.imagename"

Hi Luc, i gt problem on this code. I added in my coding but error come out. it said 'imagename is not a member of 'Resources''. what i need to do to resolve this error? thanks in advance for any assistance.
Was This Post Helpful? 0
  • +
  • -

#9 Luc001  Icon User is offline

  • D.I.C Addict

Reputation: 84
  • View blog
  • Posts: 617
  • Joined: 04-May 09

Re: Image slideshow using picture box and timer

Posted 10 April 2010 - 12:58 PM

View Postkokloong, on 08 April 2010 - 02:55 AM, said:

"pbNewImage.Image = My.Resources.imagename"

Hi Luc, i gt problem on this code. I added in my coding but error come out. it said 'imagename is not a member of 'Resources''. what i need to do to resolve this error? thanks in advance for any assistance.


Hi,

What I meant with:

pbNewImage.Image = My.Resources.imagename  ' imagename is the name of your image


You've added an Image in the resources and that image has a name, for example Sunset, then your code sould look like:

pbNewImage.Image = My.Resources.Sunset

Was This Post Helpful? 0
  • +
  • -

#10 Rickysay  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 25-October 11

Re: Image slideshow using picture box and timer

Posted 28 November 2011 - 04:15 AM

View PostLuc001, on 02 April 2010 - 02:12 AM, said:

Hi,

Here's an example how I did it.
You'll need a Picturebox named pbNewImage, a Timer and a Button named btnView.
Try this peace of code.

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
' create a number between a certain value and becomes the interval
        Dim max As Integer = 5000
        Dim rnd As New Random
        Dim rand As Integer = rnd.Next(10, max + 1)
        Dim i As Integer = 1
        Dim number(max - 1) As Integer

        For i = 0 To max - 1
            If number(i) = rand Then
                rand = rnd.Next(1, max + 1)
                i = -1
            ElseIf number(i) = 0 Then
                number(i) = rand
                rand = rnd.Next(1, max + 1)
                If i = max - 1 Then
                    Exit For
                End If
                i = -1
            End If
        Next
        Timer1.Interval = number(i)
        i += 1

        ChangeImage()
    End Sub

    Private Sub ChangeImage()

        Static Dim iImage1 As Integer

        Select Case iImage1
            Case 0

                pbNewImage.Visible = True
                pbNewImage.Image = My.Resources.imagename
                iImage1 += 1
            Case 1

                pbNewImage.Visible = True
                pbNewImage.Image = My.Resources.imagename
                iImage1 += 1
            Case 2

                pbNewImage.Visible = True
                pbNewImage.Image = My.Resources.imagename
                iImage1 += 1
            Case 3

                pbNewImage.Visible = True
                pbNewImage.Image = My.Resources.imagename
                iImage1 += 1
            Case 4

                pbNewImage.Visible = True
                pbNewImage.Image = My.Resources.imagename
                iImage1 = 0

        End Select
    End Sub
   
    Private Sub btnView_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnView.Click
        Timer1.Start()
    End Sub


What if i don't want to use buttons and want the slide to start once the program starts. What code should i put in?
Was This Post Helpful? 0
  • +
  • -

#11 _HAWK_  Icon User is offline

  • Master(Of Foo)
  • member icon

Reputation: 1043
  • View blog
  • Posts: 4,057
  • Joined: 02-July 08

Re: Image slideshow using picture box and timer

Posted 28 November 2011 - 04:29 AM

Enable the timer in the form's Shown event. Please make new threads rather than digging up these old ones.
Was This Post Helpful? 2
  • +
  • -

#12 Rickysay  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 25-October 11

Re: Image slideshow using picture box and timer

Posted 28 November 2011 - 04:58 AM

Thanks it works, It took me a while to find out where shown events was. it's actually the properties box on the lower right corner.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1