学生信息管理系统优化(一)【限制字符,限制输入密码次数】
【摘要】
1.提示三次输入错误密码,自动退出程序
Private Sub cmdOK_Click()
Dim txtSQL As String
Dim mrc As ADODB.Recordset...
1.提示三次输入错误密码,自动退出程序
Private Sub cmdOK_Click()
Dim txtSQL As String
Dim mrc As ADODB.Recordset
Dim MsgText As String
UserName = ""
If Trim(txtUserName.Text = "") Then
MsgBox "没有这个用户,请重新输入用户名!", vbOKOnly + vbExclamation, "警告"
txtUserName.SetFocus
Else
txtSQL = "select * from user_Info where user_ID = '" & txtUserName.Text & "'"
Set mrc = ExecuteSQL(txtSQL, MsgText)
If mrc.EOF Then
miCount = miCount + 1
If miCount = 1 Then
MsgBox "用户名错误,您还有两次机会!", vbOKOnly + vbExclamation, "警告"
txtUserName.SetFocus
Exit Sub
End If
If miCount = 2 Then
MsgBox "用户名错误,您还有一次机会!", vbOKOnly + vbExclamation, "警告"
txtUserName.SetFocus
Exit Sub
End If
If miCount = 3 Then
MsgBox "用户名错误,即将退出系统!", vbOKOnly + vbExclamation, "警告"
End
End If
Else
If Trim(mrc.Fields(1)) = Trim(txtPassWord.Text) Then
OK = True
mrc.Close
Me.Hide
UserName = Trim(txtUserName.Text)
FrmMain.Show
Else
miCount = miCount + 1
If miCount = 1 Then
MsgBox "密码错误,您还有两次机会!", vbOKOnly + vbExclamation, "警告"
txtPassWord.SetFocus
Exit Sub
End If
If miCount = 2 Then
MsgBox "密码错误,您还有一次机会!", vbOKOnly + vbExclamation, "警告"
txtPassWord.SetFocus
Exit Sub
End If
If miCount = 3 Then
MsgBox "密码错误,即将退出系统!", vbOKOnly + vbExclamation, "警告"
End
End If
End If
End If
End If
End Sub
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
**
2.修改各个文本框的输入字符的长度
**
通过修改属性的中的Maxlengh来实现
3.所有的姓名文本框均要限制只能添加汉字
实现代码:
Private Sub txtSID_KeyPress(KeyAscii As Integer)
Select Case KeyAscii
Case Is < 0, &H20, &H8
Case Else
KeyAscii = 0
MsgBox “姓名只能输入汉字”
End Select
End Sub
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
4.所有班号,教室,成绩,电话都限制只能添加数字
If KeyAscii >= 48 And KeyAscii <= 57 Or KeyAscii = 8 Then
Else
KeyAscii = 0
MsgBox "只能输入数字!"
End If
- 1
- 2
- 3
- 4
- 5
5.限制输入非法字符
实现代码:
If ((KeyAscii >= 48 And KeyAscii <= 57) Or (KeyAscii >= 65 And KeyAscii <= 90) Or _
(KeyAscii >= 97 And KeyAscii <= 122) Or (KeyAscii = 8)) = False Then
KeyAscii = 0
MsgBox "禁止输入非法字符!", vbOKOnly, "警告"
End If
- 1
- 2
- 3
- 4
- 5
- 6
文章来源: blog.csdn.net,作者:翟文彪,版权归原作者所有,如需转载,请联系作者。
原文链接:blog.csdn.net/zwb568/article/details/99708742
【版权声明】本文为华为云社区用户转载文章,如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱:
cloudbbs@huaweicloud.com
- 点赞
- 收藏
- 关注作者
评论(0)