[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

madushka930

10/11/2011 2:27:00 AM

anybody know how to find backspace key is pressed..

i tried this but every time i got space key is pressed.

If (Keys.Space) Then



MsgBox("space")

ElseIf Keys.Back Then





MsgBox("back")


End If
1 Answer

Peter Duniho

10/11/2011 4:01:00 AM

0

On 10/10/11 6:27 PM, madushka930 wrote:
> anybody know how to find backspace key is pressed..
>
> i tried this but every time i got space key is pressed.

The biggest thing wrong with your code is similar to what was wrong with
the last bit of code you posted here: you are using literals as if they
could magically tell you something about some other piece of data that
you did not even reference in your expression.

And as with your previous goof, C# would not have even let you use
Keys.Space or Keys.Back in a context where a boolean expression is
required. VB.NET is apparently letting you do that, but of course the
expression is meaningless. Both Keys.Space and Keys.Back are non-zero
values, so either of them could be considered "True".

Try "If e.KeyCode = Keys.Space Then … ElseIf e.KeyCode = Keys.Back … End
If" instead.

Of course, you also need to make sure you're handling KeyDown. KeyPress
only gives you character input, and of course the backspace key is not a
character (no matter what ^H thinks! :) ).

Pete