vb如何设置文本框输入只为大写字母和数字
rt下面程序该如何补充PrivateSubtext1_keypress(KeyAsciiAsInteger)SelectCaseKeyAsciiCase8'无变化,退格键...
rt
下面程序该如何补充
Private Sub text1_keypress(KeyAscii As Integer)
Select Case KeyAscii
Case 8
'无变化,退格键不屏蔽
Case Asc(" ") '32
If Text1.SelLength = 0 Then
KeyAscii = 0
End If
Case Is < Asc(0) '48
KeyAscii = 0
Case Is > Asc(9) '57
KeyAscii = 0
End Select
End Sub 展开
下面程序该如何补充
Private Sub text1_keypress(KeyAscii As Integer)
Select Case KeyAscii
Case 8
'无变化,退格键不屏蔽
Case Asc(" ") '32
If Text1.SelLength = 0 Then
KeyAscii = 0
End If
Case Is < Asc(0) '48
KeyAscii = 0
Case Is > Asc(9) '57
KeyAscii = 0
End Select
End Sub 展开
4个回答
推荐于2018-03-28 · 知道合伙人软件行家
关注
展开全部
VB可在文本框的KeyPress事件中判断键盘输入字符的keyascii参数做取舍。
KeyPress事件,此事件当用户按下和松开一个 ANSI 键时发生。
Private Sub Form_Load()
Text1 = ""
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii >= 48 And KeyAscii <= 57 Or KeyAscii >= 65 And KeyAscii <= 90 Then
Else
KeyAscii = 0
End If
End Sub
展开全部
Private Sub text1_keypress(KeyAscii As Integer)
Select Case KeyAscii
Case 8
'无变化,退格键不屏蔽
Case Asc(" ") '32
If Text1.SelLength = 0 Then
KeyAscii = 0
End If
Case Is < Asc("0") '48
KeyAscii = 0
Case Is <= Asc("9") '57
Case Is < Asc("A") '48
KeyAscii = 0
Case Is > Asc("Z") '57
KeyAscii = 0
End Select
End Sub
Select Case KeyAscii
Case 8
'无变化,退格键不屏蔽
Case Asc(" ") '32
If Text1.SelLength = 0 Then
KeyAscii = 0
End If
Case Is < Asc("0") '48
KeyAscii = 0
Case Is <= Asc("9") '57
Case Is < Asc("A") '48
KeyAscii = 0
Case Is > Asc("Z") '57
KeyAscii = 0
End Select
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Private Sub text1_keypress(KeyAscii As Integer)
Select Case KeyAscii
Case 8
'无变化,退格键不屏蔽
Case Asc("0") To Asc("9")
Case Asc("A") To Asc("Z")
Case Else' 除了以上的 都屏蔽
KeyAscii = 0
End Select
End Sub
Select Case KeyAscii
Case 8
'无变化,退格键不屏蔽
Case Asc("0") To Asc("9")
Case Asc("A") To Asc("Z")
Case Else' 除了以上的 都屏蔽
KeyAscii = 0
End Select
End Sub
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
KeyAscii = Asc(UCase(Chr(KeyAscii)))
Select Case KeyAscii
Case 8
Case Is < 48
KeyAscii = 0
Case Is < 58
Case Is < 65
KeyAscii = 0
Case Is > 90
KeyAscii = 0
End Select
Select Case KeyAscii
Case 8
Case Is < 48
KeyAscii = 0
Case Is < 58
Case Is < 65
KeyAscii = 0
Case Is > 90
KeyAscii = 0
End Select
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询