Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

VB.net button to stop code running

Posted on 2013-01-15
2
Medium Priority
?
344 Views
Last Modified: 2013-01-15
Hi

I have a VB.net Excel Add-in that populates Excel with data pulled from a SQL database.
This can run into hundreds of thousands of rows so I need the user to be able to stop
it if they want to. What is the best way to do this. Can I use a button with code behind it?

Thanks
0
Comment
Question by:Murray Brown
2 Comments
 
LVL 42

Accepted Solution

by:
Meir Rivkin earned 2000 total points
ID: 38778180
you need to have a condition in the code which populates the excel with the data.
assume you have a loop which iterates the DB rows and build the excel sheet.
have a global variable called stopProcessing As Boolean, set it to False
in your button click event set this variable to True
and inside the loop have some kind of condition:

While

If stopProcessing = True Then

'this is for next time you run the population
stopProcessing = False

 Break
End IF

End While

Open in new window

0
 

Author Closing Comment

by:Murray Brown
ID: 38778206
thanks very much
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
If you need to forecast numbers -- typically for finance -- the Windows and Mac versions of Excel 2016 have a basket of tools to get the job done.
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question