Backspace in VFP

Posted on April 25, 2005. Filed under: Visual FoxPro |

Thanks to Amit for alerting me to the fact that my backspace solution didn’t work for the mouse event.

Turns out that the solution is still simple but involves using KeyPress aswell as Valid.

Simply add a new property (eg bAllowBackspace) to your textbox baseclass and then throw the follow code in KeyPress and Valid events

KeyPress()

LPARAMETERS nKeyCode, nShiftAltCtrl
IF nKeyCode = 127 AND
This.SelStart < 1
This.bAllowBackspace = .F.
ENDIF

* other code etc

Valid()

IF This.bAllowBackspace = .F.
This.bAllowBackspace = .T.
RETURN .F.
ENDIF

* other code etc

Advertisements

Make a Comment

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

2 Responses to “Backspace in VFP”

RSS Feed for Craig Bailey on Microsoft Comments RSS Feed

This code works great. I’m glad it took me two seconds to google it. When you use this code you will get an “Invalid Input” error on your screen. If you want to suppress this message which is really just annoying, change the valid event to this

IF This.bAllowBackspace = .F.
This.bAllowBackspace = .T.
RETURN 0
ENDIF

You just return a zero instead of .F.
Here is the article on MS Knowledge base
http://support.microsoft.com/default.aspx?scid=kb%3Ben-us%3B90415
Thanks for the code Craig!!

Hi there,
Thanks for the tip regarding the return value. Nice one.
Craig


Where's The Comment Form?

Liked it here?
Why not try sites on the blogroll...

%d bloggers like this: