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


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

* other code etc


IF This.bAllowBackspace = .F.
This.bAllowBackspace = .T.

* other code etc


Make a Comment

Leave a Reply

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

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

Google+ photo

You are commenting using your Google+ 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 )


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.

You just return a zero instead of .F.
Here is the article on MS Knowledge base
Thanks for the code Craig!!

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

Where's The Comment Form?

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

%d bloggers like this: