Welcome to Dream.In.Code
Become a VB Expert!

Join 149,540 VB Programmers for FREE! Get instant access to thousands of VB experts, tutorials, code snippets, and more! There are 1,517 people online right now. Registration is fast and FREE... Join Now!




Exit Loop when a Key is Pressed

 
Reply to this topicStart new topic

Exit Loop when a Key is Pressed, Exit from For / While Loop when a Keypress Event is triggred

nealgabriel45
27 Nov, 2007 - 03:47 AM
Post #1

New D.I.C Head
Group Icon

Joined: 22 Oct, 2007
Posts: 46


Dream Kudos: 50
My Contributions
Hi All,
I am using a for loop which will execute around 100 + times; This is used for uploading some data from excel sheet to database. What i wanna know is when i press a key say Escape during the execution of the loop, i want to exit either from the function or the loop! Hope the Questino is Clear. Since Form Keydown /Keypress etc wont work during the execution of a loop, I need an alternative method. I guess this is possible with a boolean variable, But I am not able to update the variable during the execution of the loop..

Waiting for the reply..
Thanks and Regards.
Neal Gabriel
User is offlineProfile CardPM
+Quote Post

PsychoCoder
RE: Exit Loop When A Key Is Pressed
27 Nov, 2007 - 05:32 AM
Post #2

using DIC.Core;
Group Icon

Joined: 26 Jul, 2007
Posts: 9,482



Thanked: 161 times
Dream Kudos: 9050
Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, Boo.Net

My Contributions
Try having a look at DoEvents, this is available in both VB6 and all VB.Net versions. This should allow you do accomplish what you're looking for smile.gif
User is online!Profile CardPM
+Quote Post

nealgabriel45
RE: Exit Loop When A Key Is Pressed
28 Nov, 2007 - 03:46 AM
Post #3

New D.I.C Head
Group Icon

Joined: 22 Oct, 2007
Posts: 46


Dream Kudos: 50
My Contributions
Thangz a lot for the reply, I ll try it and let you know

User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/7/09 09:18PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live VB Help!

VB Tutorials

Reference Sheets

VB Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month