📄 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 = 1545
ClientLeft = 2835
ClientTop = 3480
ClientWidth = 3750
Icon = "frmLogin.frx":0000
LinkTopic = "Form1"
LockControls = -1 'True
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 103
ScaleMode = 3 'Pixel
ScaleWidth = 250
ShowInTaskbar = 0 'False
StartUpPosition = 2 '屏幕中心
Begin MSAdodcLib.Adodc adoUsers
Height = 390
Left = 2055
Top = 270
Visible = 0 'False
Width = 1500
_ExtentX = 2646
_ExtentY = 688
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 = ""
OLEDBString = ""
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.TextBox txtUserName
Height = 300
Left = 1350
TabIndex = 1
Text = "Admin"
Top = 135
Width = 2250
End
Begin VB.CommandButton cmdOK
Caption = "确定"
Default = -1 'True
Height = 375
Left = 495
TabIndex = 4
Top = 1020
Width = 1140
End
Begin VB.CommandButton cmdCancel
Cancel = -1 'True
Caption = "取消"
Height = 375
Left = 2100
TabIndex = 5
Top = 1020
Width = 1140
End
Begin VB.TextBox txtPassword
Height = 300
IMEMode = 3 'DISABLE
Left = 1350
PasswordChar = "*"
TabIndex = 3
Text = "nove"
Top = 525
Width = 2250
End
Begin VB.Label lblLabels
AutoSize = -1 'True
Caption = "用户名称(&U):"
Height = 180
Index = 0
Left = 150
TabIndex = 0
Top = 180
Width = 1170
End
Begin VB.Label lblLabels
AutoSize = -1 'True
Caption = "密码(&P):"
Height = 180
Index = 1
Left = 510
TabIndex = 2
Top = 570
Width = 810
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 Sub cmdCancel_Click()
'结束程序
End
End Sub
Private Sub cmdOk_Click()
Dim strUserName As String
Dim strPassword As String
Static intLoginTimes As Integer
If Trim(txtUserName.Text) = "" Then '如果用户名为空
MsgBox "用户名不能为空!", vbOKOnly + vbCritical, "错误"
txtUserName.SetFocus
Exit Sub
End If
'打开数据库中的 Users 表
adoUsers.Refresh
'查找用户名
adoUsers.Recordset.Find "Name='" & txtUserName.Text & "'", , adSearchForward, 1
'也可以用下面的过滤方式
'adoUser.Recordset.Filter = "Name='" & txtUserName.Text & "'"
If Not adoUsers.Recordset.EOF Then '找到记录
strUserName = adoUsers.Recordset!Name
strPassword = adoUsers.Recordset!Password
Else '没找到记录
strUserName = ""
strPassword = ""
End If
If strUserName = txtUserName.Text And strPassword = txtPassword.Text Then
adoUsers.Recordset.Close '关闭数据库中的 Users 表
Unload Me '关闭窗体
frmMDI.Show '显示主窗体
Else
'用户名或密码不对
MsgBox "用户名或密码不对!", vbOKOnly + vbInformation, "提示"
intLoginTimes = intLoginTimes + 1
If intLoginTimes >= 3 Then '超过三次
adoUsers.Recordset.Close '关闭数据库中的 Users 表
End '退出整个程序
End If
txtPassword.SetFocus '重新输入密码
SendKeys "{HOME}+{END}"
End If
End Sub
Private Sub Form_Load()
'打开用户表
OpenTable adoUsers, "Users"
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -