Solved

Exit a procedue by a keystroke in vb 6.0

Posted on 2009-04-14
2
312 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
2 Comments
 
LVL 22

Accepted Solution

by:
danaseaman earned 500 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Using "ScreenUpdating" 6 73
Visual Studio search word table and return Cell index 8 69
Passing a Text Box name to a Sub 6 99
Dinamic report to Crosstab query 9 35
I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

830 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