level 11
就是在textbox里面输入一串字符,第一个只能是字母,之后的必须是数字。就像过滤数据一样!怎样设置,求大神!
2014年05月13日 15点05分
2
level 1
Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
If TextBox1.Text.Length <= 0 Then '判断字符长度小于1个限制只能输入字母,大于1个限制只能输入数字
If ((e.KeyChar >= "A") And (e.KeyChar <= "Z")) Or ((e.KeyChar >= "a") And (e.KeyChar <= "z")) Then
e.Handled = False '输入有效
Else
e.Handled = True '输入无效
MsgBox("第一个只能输入字母")
End If
Else
If Char.IsDigit(e.KeyChar) Or e.KeyChar = Chr(8) Then
e.Handled = False '输入有效
Else
e.Handled = True '输入无效
MsgBox("只能输入数字")
End If
End If
End Sub
2014年05月21日 08点05分
3
level 1
Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
If TextBox1.Text.Length <= 0 Then '判断字符长度小于1个限制只能输入字母,大于1个限制只能输入数字
If ((e.KeyChar >= "A") And (e.KeyChar <= "Z")) Or ((e.KeyChar >= "a") And (e.KeyChar <= "z")) Then
e.Handled = False '输入有效
Else
e.Handled = True '输入无效
MsgBox("第一个只能输入字母")
End If
Else
If Char.IsDigit(e.KeyChar) Or e.KeyChar = Chr(8) Then
e.Handled = False '输入有效
Else
e.Handled = True '输入无效
MsgBox("只能输入数字")
End If
End If
End Sub
2014年05月21日 08点05分
4
level 12
不好,楼上无法抵御复制粘贴呀
用textchange吧
2014年05月22日 04点05分
5