机房收费系统总结(登陆界面)

机房收费系统总结(登陆界面)

机房收费系统完事了,但是学习的总结和积累才刚刚开始,做系统我们要积累经验,整个系统有很多的思想我们不论到什么时候都是需要用到的,这些都是我们总结积累下来的. 登陆界面.整个过程分这么几个层次

验证是否为空

验证是否超过了限制的登陆次数

验证用户名是否存在

验证密码是否正确 代码演示如下

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

慢慢积累才是王道

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值