【VB】使用ASCII码限制输入内
发布时间:2020-12-16 22:18:39 所属栏目:大数据 来源:网络整理
导读:背景: 在学生信息管理系统中有的地方需要限制输入的内容。 措施: 限制输入的文本为大小写字母以及数字 Private Sub txtSID_KeyPress(KeyAscii As Integer) Select Case KeyAscii Case 8 Case Asc("a") To Asc("z") Case Asc("0") To Asc("9") Case Asc("A"
背景:在学生信息管理系统中有的地方需要限制输入的内容。 措施:
限制输入的文本为大小写字母以及数字
Private Sub txtSID_KeyPress(KeyAscii As Integer) Select Case KeyAscii Case 8 Case Asc("a") To Asc("z") Case Asc("0") To Asc("9") Case Asc("A") To Asc("Z") Case Else KeyAscii = 0 End Select End Sub 限制特殊的字符 Private Sub txtName_KeyPress(KeyAscii As Integer) If KeyAscii > 0 And Key < 8 Then KeyAscii = 0 If KeyAscii > 8 And Key < 65 Then KeyAscii = 0 If KeyAscii > 90 And Key < 97 Then KeyAscii = 0 If KeyAscii > 122 And Key < 127 Then KeyAscii = 0 Select Case KeyAscii Case 8 End Select End Sub说实话,老是觉得这个博客有点水,毕竟是自己的能力不行,所以还请大佬们在评论区补充,我补充进正文区。(sharing is power)! (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |