?? frmlogin.frm
字號:
VERSION 5.00
Begin VB.Form frmLogin
Caption = "用戶登錄"
ClientHeight = 3840
ClientLeft = 6390
ClientTop = 4230
ClientWidth = 5475
Icon = "frmLogin.frx":0000
LinkTopic = "Form2"
Picture = "frmLogin.frx":000C
ScaleHeight = 3840
ScaleWidth = 5475
Begin VB.CommandButton cmdExit
Caption = "退出(&X)"
Height = 615
Left = 3000
Style = 1 'Graphical
TabIndex = 5
Top = 2520
Width = 1215
End
Begin VB.CommandButton cmdOk
Caption = "確定(&0)"
Default = -1 'True
Height = 615
Left = 960
Style = 1 'Graphical
TabIndex = 4
Top = 2520
Width = 1215
End
Begin VB.TextBox txtPasswd
Height = 495
IMEMode = 3 'DISABLE
Left = 2400
PasswordChar = "*"
TabIndex = 3
Top = 1320
Width = 1455
End
Begin VB.TextBox txtUser
Height = 495
Left = 2400
TabIndex = 2
Top = 480
Width = 1455
End
Begin VB.Label lblPasswd
BackStyle = 0 'Transparent
Caption = "密碼:"
BeginProperty Font
Name = "宋體"
Size = 10.5
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 1680
TabIndex = 1
Top = 1440
Width = 735
End
Begin VB.Label lblUser
BackStyle = 0 'Transparent
Caption = "用戶名:"
BeginProperty Font
Name = "宋體"
Size = 10.5
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 1440
TabIndex = 0
Top = 600
Width = 975
End
End
Attribute VB_Name = "frmLogin"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Public counter As Integer '定義重試次數
Dim SQLSt As String
Dim rs As ADODB.Recordset
Private Sub cmdExit_Click()
DBDisconnect
End
End Sub
'單擊“確定”按鈕
Private Sub cmdOK_Click()
Dim vUser As String '定義user變量,用于存儲用戶名
vUser = Trim(txtUser) ' 給user賦值
Dim pwd As String '定義pwd變量,用于存儲密碼
pwd = Trim(txtPasswd) '給密碼賦值
'沒有輸入用戶名
If Trim(vUser) = "" Then
MsgBox "請輸入用戶名", vbInformation, "警告"
txtUser.SetFocus
Exit Sub
End If
SQLStr = "select * from PasswdInfo where UserName='" + Trim(vUser) + "'"
'rs.Open SQLStr, cnn, adOpenForwardOnly, adLockReadOnly
Set rs = SQLQuery(SQLStr)
'判斷用戶是否存在
If rs.EOF 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
'判斷密碼是否正確
If rs.Fields("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
'登錄成功,保存當前用戶的信息
CurUserName = rs.Fields("UserName")
CurUserType = rs.Fields("Usertype")
Unload Me
frmMain.Show
frmMain.Enabled = True
frmMain.mnuUser.Enabled = True
frmMain.mnuSystem.Enabled = True
frmMain.mnuBook.Enabled = True
frmMain.mnuBorrow.Enabled = True
End Sub
'窗體裝載事件
Private Sub Form_Load()
counter = 0 '初始化重試次數
End Sub
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -