?? frmlogin.frm
字號:
VERSION 5.00
Begin VB.Form frmLogin
BorderStyle = 1 'Fixed Single
Caption = "登錄"
ClientHeight = 1530
ClientLeft = 45
ClientTop = 330
ClientWidth = 3990
LinkTopic = "Form1"
MaxButton = 0 'False
ScaleHeight = 1530
ScaleWidth = 3990
StartUpPosition = 2 '屏幕中心
Begin VB.CommandButton cmdCancel
Caption = "取消"
Height = 375
Left = 2520
TabIndex = 3
Top = 1080
Width = 975
End
Begin VB.CommandButton cmdOk
Caption = "登錄"
Default = -1 'True
Height = 375
Left = 720
TabIndex = 2
Top = 1080
Width = 975
End
Begin VB.TextBox txtPassword
Height = 300
IMEMode = 3 'DISABLE
Left = 1320
PasswordChar = "*"
TabIndex = 1
Top = 600
Width = 2415
End
Begin VB.TextBox txtUserName
Height = 300
Left = 1320
TabIndex = 0
Top = 240
Width = 2415
End
Begin VB.Label Label2
Caption = "密碼"
Height = 255
Left = 480
TabIndex = 5
Top = 645
Width = 735
End
Begin VB.Label Label1
Caption = "用戶名"
Height = 255
Left = 480
TabIndex = 4
Top = 285
Width = 855
End
End
Attribute VB_Name = "frmLogin"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private LoginSucceeded As Boolean '記錄是否登錄成功
Private Sub cmdCancel_Click()
'設置全局變量為 false
'不提示失敗的登錄
LoginSucceeded = False
Unload Me
End Sub
Private Sub cmdOK_Click()
userName = txtUsername.Text '全局變量:記錄當前用戶的用戶名
userPassword = txtPassword.Text '全局變量:記錄當前用戶的密碼
'檢查正確的密碼
'在此處要從數據庫中檢索是否有這個用戶,以及密碼是否正確
cn.Open
Set rs = New ADODB.Recordset
Set rs.ActiveConnection = cn
rs.LockType = adLockReadOnly
rs.CursorType = adOpenForwardOnly
rs.Open "select * from 用戶密碼表 where 用戶名 = '" & userName & "' and 密碼 = '" & userPassword & "'"
If rs.EOF Then
LoginSucceeded = False
Else
userXingMing = rs!姓名 '全局變量:記錄當前用戶的姓名
LoginSucceeded = True
End If
If LoginSucceeded = False Then
'程序執行到此,說明一定沒有登錄成功
MsgBox "無效的用戶名或密碼,請重試!", , "登錄"
txtUsername.SetFocus
txtPassword.Text = ""
SendKeys "{Home}+{End}"
Else
Me.Hide
End If
rs.Close
cn.Close
If LoginSucceeded = True Then
Unload Me
frmMain.Show
End If
End Sub
Private Sub Form_Activate()
txtUsername.Text = ""
txtPassword.Text = ""
txtUsername.SetFocus
Set cn = New ADODB.Connection
cn.ConnectionString = connectString
End Sub
Private Sub Form_Load()
LoginSucceeded = False
End Sub
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -