在vb.net中只有数字验证码我已经使用过这段代码但是当我想要更新它时,代码不允许我更改或删除它甚至不允许退格按钮工作的数字我可以改变什么制作???使用sql server数据库更新移动设备
Private Sub txtcustcontact_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtcustcontact.KeyPress
If Not IsNumeric(e.KeyChar) Then
Tip.Show("Enter Numeric Value Only ", sender)
e.KeyChar = Nothing
End If
End Sub
答案 0 :(得分:2)
您可以尝试如下:
Private Sub txtcustcontact_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtcustcontact.KeyPress
If Asc(e.KeyChar) <> 13 AndAlso Asc(e.KeyChar) <> 8 AndAlso Not IsNumeric(e.KeyChar) Then
MessageBox.Show("Please enter Numeric values only")
e.Handled = True
End If
End Sub