If you have a block of code that is stuck in a very long loop that you want to exit prematurely then you'll need two things.
- a global condition that you can test to do an
Exit - a call to
My.Application.DoEvents inside that loop
For example
Public Class Form1
Private GetOut As Boolean
.
.
.
Private Sub MySub(...)
.
.
.
GetOut = False
Do While some condition
.
.
.
If GetOut Then Exit Do
.
.
.
My.Application.DoEvents
Loop
Then the code under (for example) btnEscape would include
GetOut = True
If you don't have the DoEvents call then your application will lock up.
Reverend Jim
Carpe per diem
3,600 posts since Aug 2010
Reputation Points: 561
Solved Threads: 447
Skill Endorsements: 32
If you are just looping through a listview then why do you need to exit the loop using a buttor or menu? Surely it will exit after all of the items have been processed. Mayybe you should post the code so we can make a more informed suggestion.
Reverend Jim
Carpe per diem
3,600 posts since Aug 2010
Reputation Points: 561
Solved Threads: 447
Skill Endorsements: 32
Question Answered as of 3 Months Ago by
Reverend Jim
and
boher If you want to speed things up then do something like
ListView1.SuspendLayout
'put the loop here to update the listview
ListView1.ResumeLayout
This will stop the display of the listview from redrawing until all of the items have been processed instead of once for each change. It could make a huge difference to the performance. In order to give visual feedback to the user you might have a label that indicates something like
Processing #### of ####
Reverend Jim
Carpe per diem
3,600 posts since Aug 2010
Reputation Points: 561
Solved Threads: 447
Skill Endorsements: 32