开发者

How to represent backspace in a string?

Below is the code I am using to restrict user from entering any other characte开发者_运维问答rs except for the predefined ones. But using my code I cannot hit backspace.

How to include backspace also ?

 Dim s As String = "0123456789$"

 If s.IndexOf(e.KeyChar) = -1 Then
   e.Handled = True
 End If


a fine list of the Keys Enumeration

Keys.Back

like:

If e.KeyCode <> Keys.Back Then
  .......
End If


ControlChars.Back should give you the backspace character.


as per previous posts:

Dim s As String = "0123456789$" & ControlChars.Back

If s.IndexOf(e.KeyChar) = -1 Then
  e.Handled = True
End If
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜