📄 frmpasswd.frm
字号:
VERSION 5.00
Begin VB.Form frmPasswd
BorderStyle = 1 'Fixed Single
Caption = "用户登录"
ClientHeight = 3090
ClientLeft = 45
ClientTop = 435
ClientWidth = 4680
ControlBox = 0 'False
Icon = "frmPasswd.frx":0000
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 3090
ScaleWidth = 4680
StartUpPosition = 2 '屏幕中心
Begin VB.CommandButton cmdExit
Cancel = -1 'True
Caption = "退 出"
Height = 495
Left = 2520
TabIndex = 4
ToolTipText = "退出按钮"
Top = 2160
Width = 1215
End
Begin VB.CommandButton cmdOk
Caption = "确 定"
Default = -1 'True
Height = 495
Left = 840
TabIndex = 3
ToolTipText = "确定按钮"
Top = 2160
Width = 1215
End
Begin VB.TextBox txtUser
Height = 375
Left = 1800
TabIndex = 1
ToolTipText = "请输入用户名"
Top = 653
Width = 2055
End
Begin VB.TextBox txtPasswd
Height = 375
IMEMode = 3 'DISABLE
Left = 1800
PasswordChar = "*"
TabIndex = 2
ToolTipText = "请输入密码"
Top = 1373
Width = 2055
End
Begin VB.Label lblUser
AutoSize = -1 'True
Caption = "用户名:"
Height = 180
Left = 840
TabIndex = 5
Top = 750
Width = 720
End
Begin VB.Label lblPasswd
AutoSize = -1 'True
Caption = "密 码:"
Height = 180
Left = 840
TabIndex = 0
Top = 1470
Width = 720
End
End
Attribute VB_Name = "frmPasswd"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'定义重试次数
Public counter As Integer
'窗体装载事件
Private Sub Form_Load()
'初始化重试次数
counter = 0
End Sub
'单击确定按钮
Private Sub cmdOK_Click()
'定义user变量,用于存储用户名
Dim user As String
'给user赋值
user = Trim(txtUser.Text)
'定义pwd变量,用于存储密码
Dim pwd As String
'给密码赋值
pwd = Trim(txtPasswd.Text)
'没有输入用户名
If Trim(user) = "" Then
MsgBox "请输入用户名", vbInformation, "信息提示"
txtUser.SetFocus
Exit Sub
End If
'判断用户是否存在
If Not objPasswd.IsExistUser(user) Then
counter = counter + 1
If counter < 3 Then
MsgBox "用户名不存在,请重新输入!", vbOKOnly + vbInformation, _
"用户名错误"
txtUser.Text = ""
txtPasswd.Text = ""
txtUser.SetFocus
Exit Sub
Else
MsgBox "重试次数已到,不能再输入用户名和密码,即将退出系统!", _
vbOKOnly + vbExclamation, "用户名错误"
DBDisconnect
End
Exit Sub
End If
End If
'判断密码是否正确
objPasswd.GetInfo (user)
If objPasswd.Passwd <> pwd Then
counter = counter + 1
If counter < 3 Then
MsgBox "用户或密码错误,请重新输入!", vbOKOnly + vbInformation, _
"密码错误"
txtUser.Text = ""
txtPasswd.Text = ""
txtUser.SetFocus
Exit Sub
Else
MsgBox "重试次数已到,不能再输入用户名和密码,即将退出系统!", _
vbOKOnly + vbExclamation, "密码错误"
DBDisconnect
End
Exit Sub
End If
End If
'登录成功,将当前用户的信息保存在objCurPasswd中
objCurPasswd.UserName = objPasswd.UserName
objCurPasswd.UserType = objPasswd.UserType
'关闭自己
Unload Me
frmMain.Show
'当重新登录时用到
frmMain.Enabled = True
End Sub
'单击退出按钮
Private Sub cmdExit_Click()
DBDisconnect
End
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -