背景:
在学生信息管理系统中有的地方需要限制输入的内容。
措施:
限制输入的文本为大小写字母以及数字
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)!