📄 frmlogin.frm
字号:
VERSION 5.00
Begin VB.Form frmLogin
BackColor = &H80000014&
BorderStyle = 3 'Fixed Dialog
Caption = "登录"
ClientHeight = 3495
ClientLeft = 45
ClientTop = 330
ClientWidth = 6330
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 3495
ScaleWidth = 6330
ShowInTaskbar = 0 'False
StartUpPosition = 3 '窗口缺省
Begin VB.PictureBox Picture1
AutoSize = -1 'True
Height = 285
Left = 600
Picture = "frmLogin.frx":0000
ScaleHeight = 225
ScaleWidth = 225
TabIndex = 8
Top = 240
Width = 285
End
Begin VB.TextBox txtPassword
BackColor = &H00C0FFFF&
Height = 375
IMEMode = 3 'DISABLE
Left = 2520
PasswordChar = "*"
TabIndex = 6
Text = "123"
Top = 2160
Width = 1935
End
Begin VB.TextBox txtUser
BackColor = &H00C0FFFF&
Height = 375
Left = 2520
TabIndex = 5
Text = "wangxiaoliang"
Top = 1440
Width = 1935
End
Begin VB.CommandButton cmdExit
Height = 300
Left = 3720
Picture = "frmLogin.frx":00A4
Style = 1 'Graphical
TabIndex = 2
Top = 2880
Width = 1095
End
Begin VB.CommandButton cmdOK
Height = 300
Left = 1560
Picture = "frmLogin.frx":05FF
Style = 1 'Graphical
TabIndex = 1
Top = 2880
Width = 1095
End
Begin VB.Label Label4
BackColor = &H8000000E&
Caption = "郑州大学教师管理系统"
BeginProperty Font
Name = "MS Sans Serif"
Size = 24
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H0000FF00&
Height = 615
Left = 840
TabIndex = 7
Top = 600
Width = 5655
End
Begin VB.Label Label3
Appearance = 0 'Flat
BackColor = &H80000005&
Caption = "密码:"
BeginProperty Font
Name = "宋体"
Size = 11.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00FF0000&
Height = 255
Left = 1080
TabIndex = 4
Top = 2160
Width = 855
End
Begin VB.Label Label2
Appearance = 0 'Flat
BackColor = &H80000005&
Caption = "用户名:"
BeginProperty Font
Name = "宋体"
Size = 11.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00FF0000&
Height = 255
Left = 1080
TabIndex = 3
Top = 1560
Width = 975
End
Begin VB.Label Label1
Appearance = 0 'Flat
BackColor = &H80000005&
Caption = " 欢迎进入"
BeginProperty Font
Name = "宋体"
Size = 18
Charset = 0
Weight = 700
Underline = 0 'False
Italic = -1 'True
Strikethrough = 0 'False
EndProperty
ForeColor = &H0000FF00&
Height = 375
Left = 480
TabIndex = 0
Top = 120
Width = 5295
End
End
Attribute VB_Name = "frmLogin"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Public LoginSucceeded As Boolean
'退出窗体
Private Sub cmdExit_Click()
LoginSucceeded = False
Unload Me
End Sub
'检验数据
Private Sub cmdOK_Click()
Set rs = New ADODB.Recordset
Set rs = CN.Execute("select * From 系统用户")
If rs.EOF Then '若数据库中没有用户时,允许进入
rs.Close
Set rs = Nothing
Unload Me
Load frmMain
Exit Sub
End If
rs.MoveFirst
Do
If rs.Fields("username") = txtUser.Text Then
If rs.Fields("password") = txtPassword.Text Then
LoginSucceeded = True
rs.Close
Unload Me
Load frmMain
frmMain.Show
Exit Sub
Exit Do
End If
End If
rs.MoveNext
Loop Until rs.EOF
If rs.EOF Then '用户名或者密码不对时
MsgBox "无效密码或用户名请重试!", , "Login"
txtUser.SetFocus
End If
Exit Sub
errh: '错误处理
MsgBox Err.Description
End Sub
Private Sub Form_Load()
Dim s As String
MakeCenter frmLogin '窗体位于屏幕中间
s = MakeConnection() '创建全局ADO连接
If s <> "OK" Then
MsgBox s, , "错误!"
Unload Me
LoginSucceeded = False
End If
End Sub
Private Sub Form_Unload(Cancel As Integer)
If Not LoginSucceeded Then '如果登陆失败
CN.Close '释放连接
Set CN = Nothing
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -