Solved

VB.net button to stop code running

Posted on 2013-01-15
2
318 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction This Article is a follow-up to my Mappit! Addin Article (http://www.experts-exchange.com/A_2613.html), it was inspired by an email posting I made to EUSPRIG (http://www.eusprig.org/index.htm), I will briefly cover: 1) An overvie…
This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
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…
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.

920 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now