473,378 Members | 1,421 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

How to ESCAPE a long running FOR-NEXT ?

I want EXIT a FOR-NEXT construct via EXIT
if the user presses key ESCAPE

How can I check, whether the user presses ESCAPE
while my program is in the FOR-NEXT construct ??
Peter
Jul 21 '05 #1
3 1258
Hi Peter,

In a windows program you could add a flag (boolean value) that you set on
the Escape key in a KeyPress/Down/Up event.

In your loop, every so often do Application.DoEvents() and then check to
see if the flag is true, if so, break the loop.

--
Happy Coding!
Morten Wennevik [C# MVP]
Jul 21 '05 #2
and how you do it ?
"Morten Wennevik" wrote:
Hi Peter,

In a windows program you could add a flag (boolean value) that you set on
the Escape key in a KeyPress/Down/Up event.

In your loop, every so often do Application.DoEvents() and then check to
see if the flag is true, if so, break the loop.

--
Happy Coding!
Morten Wennevik [C# MVP]

Jul 21 '05 #3
Like this:

class MyForm:Form
{
private mStop=false;
...
//You can change following Click event handler to KeyPress/Down/Up to
capture "ESC" key storke
private btnStop_Click(object sender, Systen,EventHandler e)
{
mStop=true;
}

....

private void DoLengthyLoop()
{
for (i=0; i<1000000; i++)
{
////Do something
Application.DoEvents() ////Or if (i%10==0)
Application.DoEvents(), i.e. every 10 loops, check Stop flag.
if (mStop) break;
}
}

....
}

<Nascimento>; "Daniel" <Na**************@discussions.microsoft.com> wrote in
message news:89**********************************@microsof t.com...
and how you do it ?
"Morten Wennevik" wrote:
Hi Peter,

In a windows program you could add a flag (boolean value) that you set on the Escape key in a KeyPress/Down/Up event.

In your loop, every so often do Application.DoEvents() and then check to
see if the flag is true, if so, break the loop.

--
Happy Coding!
Morten Wennevik [C# MVP]

Jul 21 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: yawnmoth | last post by:
say i have a for loop that would iterate through every character and put a space between every 80th one, in effect forcing word wrap to occur. this can be implemented easily using a regular...
8
by: Joe | last post by:
I'm using Python 2.4 on Windows XP SP2. I'm trying to receive a command line argument that is a newline (\n) Here is the command line to use sample.py "\n" Here is a sample.py script
3
by: Terry Asher | last post by:
The following script does NOT escape the Apostrophe. Meaning when you mouseover the image the Alt tag says this: DMACC, It and then it stops. <SCRIPT Language="JavaScript"> var pos = "DMACC,...
1
by: Grant Allen | last post by:
I know this has been asked before - I've trawled through the mail archives and FAQs looking for any info, and only found "that's the way it works" answers. Basically, I want to turn off backslash...
6
by: Walter L. Preuninger II | last post by:
I need to convert escape sequences entered into my program to the actual code. For example, \r becomes 0x0d I have looked over the FAQ, and searched the web, with no results. Is there a...
18
by: Steve Litvack | last post by:
Hello, I have built an XMLDocument object instance and I get the following string when I examine the InnerXml property: <?xml version=\"1.0\"?><ROOT><UserData UserID=\"2282\"><Tag1...
12
by: Jeff S | last post by:
In a VB.NET code behind module, I build a string for a link that points to a JavaScript function. The two lines of code below show what is relevant. PopupLink = "javascript:PopUpWindow(" &...
4
by: Dan | last post by:
I'm using asp.net c# in my code behind I coded the following: ButtonAsynchronous.Attributes.Add("onclick", @" setTimeout( ""UpdateImg('AnimatedProgress','images/running.gif');"" , 50); "); ...
131
by: Lawrence D'Oliveiro | last post by:
The "escape" function in the "cgi" module escapes characters with special meanings in HTML. The ones that need escaping are '<', '&' and '"'. However, cgi.escape only escapes the quote character if...
3
by: scopnd | last post by:
Hi, I'm new to PHP and I am working through tutorials. I am running PHP 5.2.6, on windows xp. I am having problem with escape characters, they do not seem to work. The below code example should...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.