?? frmlogin.frm
字號:
VERSION 5.00
Object = "{67397AA1-7FB1-11D0-B148-00A0C922E820}#6.0#0"; "MSADODC.OCX"
Begin VB.Form frmLogin
BorderStyle = 3 'Fixed Dialog
Caption = "登錄"
ClientHeight = 2370
ClientLeft = 2910
ClientTop = 2430
ClientWidth = 3960
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 2370
ScaleWidth = 3960
ShowInTaskbar = 0 'False
Begin MSAdodcLib.Adodc adoUser
Height = 312
Left = 2400
Top = 2160
Visible = 0 'False
Width = 1452
_ExtentX = 2566
_ExtentY = 582
ConnectMode = 0
CursorLocation = 3
IsolationLevel = -1
ConnectionTimeout= 15
CommandTimeout = 30
CursorType = 3
LockType = 3
CommandType = 8
CursorOptions = 0
CacheSize = 50
MaxRecords = 0
BOFAction = 0
EOFAction = 0
ConnectStringType= 1
Appearance = 1
BackColor = -2147483643
ForeColor = -2147483640
Orientation = 0
Enabled = -1
Connect = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Stud97.mdb;Persist Security Info=False"
OLEDBString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Stud97.mdb;Persist Security Info=False"
OLEDBFile = ""
DataSourceName = ""
OtherAttributes = ""
UserName = ""
Password = ""
RecordSource = ""
Caption = "Adodc1"
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋體"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
_Version = 393216
End
Begin VB.CommandButton cmdCancel
Caption = "取消"
Height = 312
Left = 2003
TabIndex = 6
Top = 1800
Width = 1095
End
Begin VB.CommandButton cmdOk
Caption = "確定"
Default = -1 'True
Height = 312
Left = 803
TabIndex = 5
Top = 1800
Width = 1095
End
Begin VB.TextBox txtPassword
Height = 264
IMEMode = 3 'DISABLE
Left = 1344
MaxLength = 16
PasswordChar = "#"
TabIndex = 4
Text = "123456"
Top = 1200
Width = 2052
End
Begin VB.TextBox txtUserID
Height = 264
Left = 1344
MaxLength = 16
TabIndex = 3
Text = "ADMIN"
Top = 840
Width = 2052
End
Begin VB.Label Label3
AutoSize = -1 'True
Caption = "用戶密碼"
Height = 180
Left = 504
TabIndex = 2
Top = 1248
Width = 720
End
Begin VB.Label Label2
AutoSize = -1 'True
Caption = "用 戶 名"
Height = 180
Left = 504
TabIndex = 1
Top = 888
Width = 732
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "學生信息管理系統"
BeginProperty Font
Name = "華文彩云"
Size = 16.5
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 336
Left = 600
TabIndex = 0
Top = 240
Width = 2700
End
End
Attribute VB_Name = "frmLogin"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'用戶登錄窗體frmLogin
Option Explicit
Dim Rs As ADODB.Recordset '定義記錄集變量
Private Sub cmdCancel_Click()
Unload Me
End Sub
Private Sub cmdOk_Click()
Static intErr As Integer '靜態變量累加出錯次數
adoUser.Refresh '刷新記錄集(關鍵語句)
Set Rs = adoUser.Recordset '設置記錄集變量
Rs.Find "用戶名='" & txtUserID.Text & "'"
If Not Rs.EOF Then '若用戶名正確
'檢查密碼
If Rs("密碼") = txtPassword.Text Then '若密碼正確
gstrUser = txtUserID.Text '存用戶名
If Rs("權限") = "管理員" Then '存用戶權限
gblnPurview = True
Else
gblnPurview = False
End If
frmMain.Show '顯示主窗體
Unload Me '卸載本窗體
Else '若密碼錯誤
intErr = intErr + 1 '錯誤數+1
If intErr = 3 Then '若出錯3次,退出系統
Set Rs = Nothing
Unload Me
Else '若出錯不足3次,重新輸入
MsgBox "密碼輸入錯誤,請重新輸入!", vbExclamation
With txtPassword '焦點返回密碼框
.SelStart = 0
.SelLength = Len(.Text)
.SetFocus
End With
End If
End If
Else '若用戶名錯誤
intErr = intErr + 1 '錯誤數+1
If intErr = 3 Then '若出錯3次,退出系統
Set Rs = Nothing
Unload Me
Else '若出錯不足3次,重新輸入
MsgBox "用戶名輸入錯誤,請重新輸入!", vbExclamation
With txtUserID '焦點返回用戶框
.SelStart = 0
.SelLength = Len(.Text)
.SetFocus
End With
End If
End If
End Sub
Private Sub Form_Initialize()
ChDrive App.Path
ChDir App.Path
End Sub
Private Sub Form_Load() '窗體加載
cmdOk.Default = True '“確定”按鈕為回車鍵缺省按鈕
Dim sql As String
sql = "SELECT * FROM 用戶" 'SQL語句用于創建動態記錄集
adoUser.RecordSource = sql '設置記錄源為動態記錄集
End Sub
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -