机房收费系统——登录

前言

对机房系统有了宏观把控以后,可以开始登录窗体了。先别急着敲代码,先搞懂要满足什么功能。登录窗体要做到用户能成功登录,并且有三种权限的设置。了解了要满足的功能,要对思路进行梳理,制作流程图就可以帮我们很好的梳理思路。

这里写图片描述

部分代码展示

限制登录次数代码

miCount = miCount + 1
If miCount = 1 Then
    MsgBox "密码输入错误,您还有两次机会!", 48, "警告"
    txtPassword.SetFocus
    txtPassword.Text = ""
    Exit Sub
Else
    If miCount = 2 Then
        MsgBox "密码输入错误,您还有一次机会!", 48, "警告"
        txtPassword.SetFocus
        txtPassword.Text = ""
        Exit Sub
    Else
        If miCount = 3 Then
            MsgBox "密码输入错误,程序即将关闭!", 48, "警告"
            txtPassword.SetFocus
            txtPassword.Text = ""
            Me.Hide
            Exit Sub
        End If
    End If
End If

权限限制代码

If Trim(mrc.Fields(2)) = "一般用户" Then
   frmMain.userName.Enabled = True
   frmMain.opeMenu.Enabled = False
   frmMain.opeMenu.Visible = False
   frmMain.adminMenu.Enabled = False
   frmMain.adminMenu.Visible = False
End If
    
If Trim(mrc.Fields(2)) = "操作员" Then
    frmMain.userName.Enabled = True
    frmMain.opeMenu.Enabled = True
    frmMain.adminMenu.Enabled = False
    frmMain.adminMenu.Visible = False
End If

限制字符代码

Private Sub txtPassWord_KeyPress(KeyAscii As Integer)
	If KeyAscii > 31 And KeyAscii < 48 Or KeyAscii > 57 And KeyAscii < 65 Or KeyAscii > 90 And KeyAscii > 122 And KeyAscii < 127 Then
        MsgBox "不能输入特殊字符!", 48, "警告"
        KeyAscii = 0
    End If
End Sub

Private Sub txtUserName_KeyPress(KeyAscii As Integer)
    If KeyAscii > 31 And KeyAscii < 48 Or KeyAscii > 57 And KeyAscii < 65 Or KeyAscii > 90 And KeyAscii > 122 And KeyAscii < 127 Then
        MsgBox "不能输入特殊字符!", 48, "警告"
        KeyAscii = 0
    End If
End Sub

结语

登录窗体是比较容易的,虽然容易,还是先画流程图能让思路更加清晰哦!如果你的方法能让代码更少,欢迎交流!
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 10
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值