Vb.net - Key press event

How to Use Delete Key In Key Press event

Page 1 of 1

3 Replies - 23806 Views - Last Post: 16 July 2010 - 10:21 AM Rate Topic: -----

#1 mano.mykingdom  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 13-July 10

Vb.net - Key press event

Posted 16 July 2010 - 02:42 AM

What is the ASCII code for delete key in keyboard. how to use it in key press event

Ascii code for delete Key in keyboard. how to use it in vb.net key press event
Is This A Good Question/Topic? 0
  • +

Replies To: Vb.net - Key press event

#2 _HAWK_  Icon User is offline

  • Master(Of Foo)
  • member icon

Reputation: 1062
  • View blog
  • Posts: 4,138
  • Joined: 02-July 08

Re: Vb.net - Key press event

Posted 16 July 2010 - 03:10 AM

You can use Select Case to handle the event.

'key press event
Select Case Convert.ToInt32(e.KeyChar)
   Case 48 to 57  ' numbers
   Case 65 to 122 ' letters
   Case Keys.Delete
      e.Handled = True ' true means the keypress is suppressed
End Select


Ascii values.
Was This Post Helpful? 1
  • +
  • -

#3 ItIntern3  Icon User is offline

  • D.I.C Head

Reputation: 6
  • View blog
  • Posts: 97
  • Joined: 14-July 10

Re: Vb.net - Key press event

Posted 16 July 2010 - 06:57 AM

I believe that the ASCII value for the delete key is 127 in decimal form. Are you looking for the press key event to occur within a windows application (GUI app)?
Was This Post Helpful? 0
  • +
  • -

#4 born2c0de  Icon User is offline

  • printf("I'm a %XR",195936478);
  • member icon

Reputation: 180
  • View blog
  • Posts: 4,667
  • Joined: 26-November 04

Re: Vb.net - Key press event

Posted 16 July 2010 - 10:21 AM

@ItIntern3: You are correct. ASCII code for DEL is 0x7F or 127 in decimal.
It is however recommended that you use the Keys.Delete constant for the sake of portability.

This post has been edited by born2c0de: 16 July 2010 - 10:44 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1