機房收費系統——登入
阿新 • • 發佈:2018-12-08
前言
對機房系統有了巨集觀把控以後,可以開始登入窗體了。先別急著敲程式碼,先搞懂要滿足什麼功能。登入窗體要做到使用者能成功登入,並且有三種許可權的設定。瞭解了要滿足的功能,要對思路進行梳理,製作流程圖就可以幫我們很好的梳理思路。
部分程式碼展示
限制登入次數程式碼
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