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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

NKEYCODE = 19 Problem 1

Status
Not open for further replies.

redzombi5k

Programmer
Jan 21, 2009
22
US
Hi guys,
I have come across a strange problem with the keypress event of an editbox.
I am tring to set up a hot key for 'Ctrl+S', and it appears to run properly, only after the code has run it places a '' in my edit box. After checking my code and finding nothnig wrong, I changed the nKeyCode to 18 'Ctrl+R' and ran it with absolutly no problem!
Can anyone else reproduce this, or have a suggestion?
my code is as follows...

DO CASE
CASE NKEYCODE = 4 && CTRL + D
THIS.Value = ALLTRIM(THIS.Value) + TRANSFORM(DATE())
CASE NKEYCODE = 19 && CTRL + S
THIS.Value = ALLTRIM(THIS.Value) + CHR(13) + 'No Signature on Soft Copy, Emailed Advisor' + IIF(THISFORM.TXTAdvNum.Value <> '', ' ' + ALLTRIM(THISFORM.TXTAdvNum.Value),'') + ' on - ' + TRANSFORM(DATE())
CASE NKEYCODE = 18 && CTRL + R
THIS.Value = ALLTRIM(THIS.Value) + CHR(13) + 'Need Rental Agreement - ' + TRANSFORM(DATE())
ENDCASE

Thanks!
 
Not sure I understand the problem. Are you saying that everything works OK, but you don't want a strange character appearing in the text box?

If so, add NODEFAULT to the code. That will allow the key to be trapped, but nothing will appear in the textbox.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Sorry if I was unclear, yes I am saying I do not want that strange character to show up. I am not putting it there, it just shows up, but only when I use 'Ctrl+S'. If I change the above code to use a different hot key, then the strange character does not appear. Crazy, I put the following code in to remove it, but the strange character does not appear until after all code in the keypress event has run...

WAIT WINDOW 'now removing the '
this.Value = CHRTRAN(ALLTRIM(this.Value),'','')
WAIT WINDOW 'should be gone now'

the above code will remove the strange charater after any other key is pressed, but that is not exactly what I am going for.
 
Ahh! Mike, Thanks! That solved it I just put the nodefault directly after the code for my hot key and strange charater gone, however I still wonder why this was happening...
 
As am I, by the way mine was a edit box not a text box so mabey that makes a difference, but im just as well to let this mystery die, and call it solved! :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top