Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

KeyPress Event code sample???

Status
Not open for further replies.

Ellis

Programmer
Dec 26, 1999
1
US
I have a textbox into which a character-variable is typed. I would like to know if the ENTER key is pressed. If a variable is entered into the textbox a certain action takes place. However, if the ENTER button is pressed without a variable being entered a second action takes place. I'm not sure how to write the code to identify the ENTER button. (LParameters nKeyCode, nShiftAltCtrl) Please help??? [sig][/sig]
 
Since the Enter key is used to exit a field as can Tab or a Mouse Movement it looks like the code you're looking for should simply go in the Valid Method. The first IF in the code below is not needed if you place this in the Valid or Lost Focus Event. If you elect to place this code in KeyPress or InteractiveChange then you would need to trap the Enter key.
[tt]
IF nKeyCode = 13
* code that Enter key was pressed such as:
IF EMPTY(This.Value)
MessageBox("Please enter a value")
RETURN 0
ENDIF
ENDIF[/tt] [sig]<p>John Durbin<br><a href=mailto: john@johndurbin.com> john@johndurbin.com</a><br><a href= </a><br>MCP Visual FoxPro<br>
<br>
ICQ #9466492<br>
ICQ VFP ActiveList #73897253[/sig]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top