Solved

Exit a procedue by a keystroke in vb 6.0

Posted on 2009-04-14
2
311 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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
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…
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…

816 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