Solved

VB.net button to stop code running

Posted on 2013-01-15
2
319 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:murbro
2 Comments
 
LVL 42

Accepted Solution

by:
sedgwick earned 500 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:murbro
ID: 38778206
thanks very much
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Select/Copy row and pasting it lower in sheet 7 23
If help 9 50
Time difference between dates without weekend 16 31
Embeded Images 13 14
How to quickly and accurately populate Word documents with Excel data, charts and images (including Automated Bookmark generation) David Miller (dlmille) Synopsis In this article you’ll learn how to use ExcelToWord! to copy data,charts, shapes …
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…

825 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