用VB怎么使文本框中只能输入字母
新建一个文本框,要求只能输入英文字母,输入其他的就会弹出一个对话框(好像要用msgbox,我暂时还没学)...
新建一个文本框,要求只能输入英文字母,输入其他的就会弹出一个对话框(好像要用msgbox,我暂时还没学)
展开
2014-01-11
展开全部
你好,暂时可以这样做(选择Key_Press事件)Private Sub Text1_KeyPress(KeyAscii As Integer)
Select Case KeyAscii
If Not ((KeyAscii>=Asc("A") And KeyAscii<=Asc("Z") Or (KeyAscii>=Asc("a") And KeyAscii<=Asc("z")) Or (KeyAscii=vbKeyBack))
KeyAscii = 0
End Select
End Sub
Select Case KeyAscii
If Not ((KeyAscii>=Asc("A") And KeyAscii<=Asc("Z") Or (KeyAscii>=Asc("a") And KeyAscii<=Asc("z")) Or (KeyAscii=vbKeyBack))
KeyAscii = 0
End Select
End Sub
展开全部
比如
Private Sub Text_KeyPress(KeyAscii As Integer)
If (KeyAscii >=Asc("a") and KeyAscii <= Asc("z")) or (KeyAscii >= Asc("A") and KeyAscii <=Asc("Z")) Then
KeyAscii = KeyAscii
else
KeyAscii=0
End If
End Sub
Private Sub Text_KeyPress(KeyAscii As Integer)
If (KeyAscii >=Asc("a") and KeyAscii <= Asc("z")) or (KeyAscii >= Asc("A") and KeyAscii <=Asc("Z")) Then
KeyAscii = KeyAscii
else
KeyAscii=0
End If
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询