?
Solved

Exit a procedue by a keystroke in vb 6.0

Posted on 2009-04-14
2
Medium Priority
?
317 Views
Last Modified: 2013-12-26
I have a for loop in one of the command button code of the vb applicatoin. Is there a way I can exit this for loop my hitting some keys..I am looking for key_stroke process to end a for loop
0
Comment
Question by:Aiysha
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 22

Accepted Solution

by:
danaseaman earned 2000 total points
ID: 24140462
Try this. Uses Do/Loop but could be For/Next:

Option Explicit
 
Dim bEscape             As Boolean
 
Private Sub Command1_Click()
   Dim i                As Long
   Do
      DoEvents
      If bEscape Then
         bEscape = False
         Debug.Print "Exiting loop"
         Exit Do
      End If
   Loop
End Sub
 
Private Sub Form_KeyPress(KeyAscii As Integer)
   If KeyAscii = 27 Then
      bEscape = True
   End If
End Sub
 
Private Sub Form_Load()
   Me.KeyPreview = True
End Sub

Open in new window

0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

770 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