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?
Image slideshow using picture box and timer
Page 1 of 111 Replies - 43363 Views - Last Post: 28 November 2011 - 04:58 AM
Replies To: Image slideshow using picture box and timer
#2
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
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
#3 Guest_kok loong*
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?
#4
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.
#5
Re: Image slideshow using picture box and timer
Posted 29 March 2010 - 01:45 AM
kok 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.
#6
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..
#7
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.
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
#8
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.
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.
#9
Re: Image slideshow using picture box and timer
Posted 10 April 2010 - 12:58 PM
kokloong, 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 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
#10
Re: Image slideshow using picture box and timer
Posted 28 November 2011 - 04:15 AM
Luc001, 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.
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?
#11
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.
#12
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.
Page 1 of 1
|
|

New Topic/Question
Reply





MultiQuote





|