机房收费系统总结(登陆界面)
机房收费系统完事了,但是学习的总结和积累才刚刚开始,做系统我们要积累经验,整个系统有很多的思想我们不论到什么时候都是需要用到的,这些都是我们总结积累下来的. 登陆界面.整个过程分这么几个层次
验证是否为空
验证是否超过了限制的登陆次数
验证用户名是否存在
验证密码是否正确 代码演示如下
Private Sub cmdOK_Click()
Dim intCounts As Integer '用于保存用户请求验证次数
Dim ObjRst As Recordset
Dim StrSQL As String
'判断输入框是否为空
If Trim(txtUserID.Text) = "" Then
MsgBox "请输入用户名", vbOKOnly + vbExclamation, "提示"
txtUserID.SetFocus
Exit Sub
End If
If Trim(txtPWD.Text) = "" Then
MsgBox "请输入密码", vbOKOnly + vbExclamation, "提示"
txtPWD.SetFocus
Exit Sub
End If
intCounts = intCounts + 1 '计算登录次数
If intCounts > MaxLoginTimes Then '验证是否登陆次数超过限制
MsgBox "登陆次数超过限制!", vbCritical, "警告"
End
Else
'检查是否存在指定用户
StrSQL = "select * from User_Info where User_ID = '" & txtUserID.Text & "'" Set ObjRst = ExecuteSQL(StrSQL)
If ObjRst.EOF Then
MsgBox "用户名错误!", vbOKOnly + vbCritical, "警告"
txtUserID.SetFocus
txtUserID.SelStart = 0
txtUserID.SelLength = Len(txtName.Text)
Exit Sub
Else
'检查密码是否正确
If Trim(ObjRst.Fields(3)) <> Trim(txtPWD.Text) Then
MsgBox "密码输入错误!", vbOKOnly + vbCritical, "警告"
txtUserID.SetFocus
txtUserID.SelStart = 0
txtUserID.SelLength = Len(txtPW.Text)
Exit Sub
Else
Unload Me '卸载登录窗体
frmMain.Show
End If
End If
End If
End Sub
当然这只是最最简单的登陆界面还可以加入字符限制比如限制只能输入数字和英文字符如下
Public Function Check(ByVal Str2 As String) As Boolean
Dim i As Integer
Check = False
For i = 0 To Len(Str2) - 1
str1 = Mid(Str2, i + 1, 1)
If (Asc(str1) >= 45 And Asc(str1) <= 57) Or (Asc(str1) >= 65 And Asc(str1) <= 90) Or (Asc(str1) >= 97 And Asc(str1) <= 122) Or (Asc(str1) = 8) Or (Asc(str1) = 13) Then
Check = False
Else
Check = True
Exit Function
End If
Next i
End Function
慢慢积累才是王道