vb.net如何限制textbox的输入类型,如 年龄 限制输入数字,姓名限制输入字符,身份证限制输入18位数字????
新手,麻烦各位帮帮忙!!!
[解决办法]
请用现成的MaskedTextBox
[解决办法]
'限制文本框只能输入数字,英文及中文,特殊符号不可输入
Private Sub TXB_KQNAME_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TXB_KQNAME.KeyPress
If (Not Char.IsLetterOrDigit(e.KeyChar)) And (Not Char.IsControl(e.KeyChar)) Then
e.Handled = True
End If
End Sub
'文本框可输入数字、“.”,其他概不接受
Private Sub txb_xz_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txb_xz.KeyPress
If Not ((e.KeyChar >= "0") And (e.KeyChar <= "9") Or (e.KeyChar = ".") Or e.KeyChar = Chr(8)) Then
e.Handled = True
End If
End Sub