| | |
How to stop a loop displaying photos?
Please support our VB.NET advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Sep 2008
Posts: 27
Reputation:
Solved Threads: 0
Hello.
I am writing an application that displays photos. I need to be able to stop the SlideShow when the user presses the "Stop" button. Right now, what's happening when the Stop button is pressed, is a public variable, bStop, is set to True. It works sort-of, and it also takes a long time. There must be a better way. Any ideas?
Thanks
I am writing an application that displays photos. I need to be able to stop the SlideShow when the user presses the "Stop" button. Right now, what's happening when the Stop button is pressed, is a public variable, bStop, is set to True. It works sort-of, and it also takes a long time. There must be a better way. Any ideas?
Thanks
vbnet Syntax (Toggle Plain Text)
Private Sub SlideShow() Dim x As Integer = 0 With cboFileNames For x = 0 To (.Items.Count) - 1 If bStop Then Exit For PictureBox1.Image = Image.FromFile(.Items(x).ToString) My.Application.DoEvents() Threading.Thread.Sleep(3000) Next End With End Sub
Last edited by cscgal; Oct 13th, 2008 at 12:24 pm. Reason: Fixed code tag
Hi,
Use Timer control instead of Thread.Sleep (). Because ur application will freeze for the given milliseconds.
if you use timer control, you can disable the timer when stop button is clicked.
To use timer, change the Following
> Use X as Global variable
> Draw a Timer Control and Set Enabled Property to True and Interval property to 3000
> Place the above code into Timer_Tick event
Note : Also Check the x value whether it is inside upper and lower bound value inside TImer1_Tick Event
Use Timer control instead of Thread.Sleep (). Because ur application will freeze for the given milliseconds.
if you use timer control, you can disable the timer when stop button is clicked.
To use timer, change the Following
> Use X as Global variable
> Draw a Timer Control and Set Enabled Property to True and Interval property to 3000
> Place the above code into Timer_Tick event
VB Syntax (Toggle Plain Text)
Dim x As Integer = 0 Private Sub Timer1_Tick ( ... ) With cboFileNames 'For x = 0 To (.Items.Count) - 1 'If bStop Then Exit For PictureBox1.Image = Image.FromFile(.Items(x).ToString) My.Application.DoEvents() 'Threading.Thread.Sleep(3000) 'Next x = x + 1 End With End Sub Private Sub ButtonStop_Click( .. ) Timer1.Enabled = False End Sub
Note : Also Check the x value whether it is inside upper and lower bound value inside TImer1_Tick Event
Last edited by selvaganapathy; Oct 13th, 2008 at 8:22 am.
Selva ![]() |
Other Threads in the VB.NET Forum
- Previous Thread: embeding excel spreadsheet into stand alone Vb.net program
- Next Thread: How Could I Do Nested Datagridview in vb.net
Views: 985 | Replies: 1
| Thread Tools | Search this Thread |
Tag cloud for VB.NET
"crystal .net .net2005 2008 access add application array assignment basic box button buttons center class click code combo convert cpu data database datagrid datagridview design designer dissertation dissertations dissertationthesis dosconsolevb.net editvb.net employees error excel exists firewall function image images isnumericfuntioncall listview login map math memory mobile module msaccess mssqlbackend mysql navigate net opacity page pan picturebox port print printing printpreview problem record refresh regex reports" reuse right-to-left save savedialog search serial socket sorting sql sqldatbase storedprocedure string structures studio temp textbox timer txttoxmlconverter upload useraccounts usercontol usercontrol vb vb.net vb.nettoolboxvisualbasic2008sidebar vb2008 vbnet vista visual visualbasic visualbasic.net visualstudio2008 web wpf xml





