?
Solved

key presses

Posted on 2003-02-28
2
Medium Priority
?
219 Views
Last Modified: 2010-05-01
get VB to responed to a press of the enter key
0
Comment
Question by:col_jack_oneal
2 Comments
 
LVL 18

Accepted Solution

by:
bobbit31 earned 200 total points
ID: 8042893
make sure to set your form's keypreview property to true and then:

Private Sub Form_KeyPress(keyascii As Integer)
   if keyascii = 13 then
     msgbox "enter pressed"
  end if
End Sub
0
 
LVL 2

Expert Comment

by:Sweat
ID: 8042902
col jack,

The KeyPress event can identify the ENTER key and you can then do what you want with it.

Private Sub Text1_KeyPress(KeyAscii As Integer)

     If KeyAscii = 13 Then
        KeyAscii=0
        ' Your code here
        Exit Sub
     End If

Hope this helps,

Sweat

0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying 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

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…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

616 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