当他/她输入错误输入整数系列时,我无法使用键盘中的Backspace按钮更改或编辑用户输入的内容...请帮帮我...
Private Sub tbx3_KeyPress(sender As Object, e As KeyPressEventArgs) Handles tbx3.KeyPress
If CInt(Val(e.KeyChar)) = 8 Then
Return
End If
Dim allowedchar As String = "1234567890"
If Not (allowedchar.Contains(e.KeyChar)) Then
e.KeyChar = CChar(e.KeyChar)
e.Handled = True
End If
End Sub
答案 0 :(得分:0)
试试这个
If (Microsoft.VisualBasic.Asc(e.KeyChar) < 48) _
Or (Microsoft.VisualBasic.Asc(e.KeyChar) > 57) Then
e.Handled = True
End If
If (Microsoft.VisualBasic.Asc(e.KeyChar) = 8) Then
e.Handled = False
End If