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
精彩评论