2个回答
2013-05-13
展开全部
长度有maxlenght可以设置数字中文英文可以看输入的asc码。数字最简单 ,isnumeric判断一下就可以了。
2013-05-13
展开全部
'只允许汉字Private Sub Text1_KeyPress(KeyAscii As Integer)
If (KeyAscii < -20319 Or KeyAscii > -3652) And KeyAscii <> 8 Then KeyAscii = 0
End Sub'只允许字母Private Sub Text1_KeyPress(KeyAscii As Integer)
If (Asc(UCase(Chr(KeyAscii))) > 90 Or Asc(UCase(Chr(KeyAscii))) < 65) And KeyAscii <> 8 Then KeyAscii = 0
End Sub'只允许数字(0-9)Private Sub Text1_KeyPress(KeyAscii As Integer)
If (KeyAscii < 48 Or KeyAscii > 57) And KeyAscii <> 8 Then KeyAscii = 0
End Sub'限制长度可以设置maxlength属性'PS:以上方法只是限制键盘输入,无法过滤粘贴,你可以在change事件中逐字筛选
If (KeyAscii < -20319 Or KeyAscii > -3652) And KeyAscii <> 8 Then KeyAscii = 0
End Sub'只允许字母Private Sub Text1_KeyPress(KeyAscii As Integer)
If (Asc(UCase(Chr(KeyAscii))) > 90 Or Asc(UCase(Chr(KeyAscii))) < 65) And KeyAscii <> 8 Then KeyAscii = 0
End Sub'只允许数字(0-9)Private Sub Text1_KeyPress(KeyAscii As Integer)
If (KeyAscii < 48 Or KeyAscii > 57) And KeyAscii <> 8 Then KeyAscii = 0
End Sub'限制长度可以设置maxlength属性'PS:以上方法只是限制键盘输入,无法过滤粘贴,你可以在change事件中逐字筛选
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询