📄 login.frm
字号:
VERSION 5.00
Begin VB.Form Form2
BackColor = &H00FFC0C0&
BorderStyle = 1 'Fixed Single
Caption = "系统登录"
ClientHeight = 3510
ClientLeft = 3525
ClientTop = 2880
ClientWidth = 5100
Icon = "login.frx":0000
LinkTopic = "Form2"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 3510
ScaleWidth = 5100
StartUpPosition = 2 '屏幕中心
Visible = 0 'False
Begin VB.CommandButton cmdCancel
BackColor = &H00FFC0C0&
Caption = "离 开"
Height = 495
Left = 3000
Style = 1 'Graphical
TabIndex = 6
Top = 2880
Width = 1215
End
Begin VB.CommandButton cmdOK
BackColor = &H00FFC0C0&
Caption = "登 录"
Height = 495
Left = 600
Style = 1 'Graphical
TabIndex = 2
Top = 2880
Width = 1215
End
Begin VB.TextBox txtPassword
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
IMEMode = 3 'DISABLE
Left = 1440
PasswordChar = "*"
TabIndex = 1
Top = 2040
Width = 2535
End
Begin VB.TextBox txtUserName
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 1440
TabIndex = 0
Text = "admin"
Top = 1200
Width = 2535
End
Begin VB.Label Label3
Alignment = 2 'Center
BackColor = &H00FFC0C0&
Caption = "密 码:"
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 240
TabIndex = 5
Top = 2040
Width = 975
End
Begin VB.Label Label2
Alignment = 2 'Center
BackColor = &H00FFC0C0&
Caption = "用户名:"
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 240
TabIndex = 4
Top = 1200
Width = 975
End
Begin VB.Label Label1
Alignment = 2 'Center
BackColor = &H00FFC0C0&
Caption = "教务管理系统"
BeginProperty Font
Name = "华文行楷"
Size = 21.75
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 960
TabIndex = 3
Top = 360
Width = 3135
End
End
Attribute VB_Name = "Form2"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Attribute VB_Ext_KEY = "RVB_UniqueId" ,"41FF01D903CC"
Attribute VB_Ext_KEY = "RVB_ModelStereotype" ,"Form"
Public OK As Boolean
'记录按“确定”的次数
Dim miCount As Integer
Private Sub cmdCancel_Click()
OK = False
Me.Hide
End Sub
Private Sub cmdOK_Click()
'用来存放SQL语句
Dim txtSQL As String
'用来存放记录集对象
Dim mrc As ADODB.Recordset
'用来存放返回信息
Dim MsgText As String
UserName = ""
'判断输入用户名是否为空
If Trim(txtUserName.Text = "") Then
MsgBox "没有这个用户,请重新输入用户名!", vbOKOnly + vbExclamation, "警告"
txtUserName.SetFocus
Else
'查询指定用户名的记录
txtSQL = "select * from User_info where User_id = " & "'" & Trim(txtUserName.Text) & "'"
'执行查询语句
Set mrc = ExecuteSQL(txtSQL, MsgText)
If mrc.EOF = True Then
MsgBox "没有这个用户,请重新输入用户名!", vbOKOnly + vbExclamation, "警告"
txtUserName.SetFocus
Else
'判断密码是否正确
If Trim(mrc.Fields(1)) = Trim(txtPassword.Text) Then
OK = True
mrc.Close
Me.Hide
UserName = Trim(txtUserName.Text)
Else
MsgBox "输入密码不正确,请重新输入!", vbOKOnly + vbExclamation, "警告"
txtPassword.SetFocus
txtPassword.Text = ""
End If
End If
End If
'记载输入密码次数
miCount = miCount + 1
If miCount = 3 Then
Me.Hide
End If
Exit Sub
End Sub
Private Sub Form_Load()
OK = False
miCount = 0
End Sub
'在输完密码之后,检测按下的是否是回车
Private Sub txtPassword_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then
Call cmdOK_Click
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -