Solved

VB.net button to stop code running

Posted on 2013-01-15
2
315 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
Comment Utility
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
Comment Utility
thanks very much
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

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.
This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.

762 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

10 Experts available now in Live!

Get 1:1 Help Now