📄 frmlogin.frm
字号:
VERSION 5.00
Begin VB.Form frmLogin
BorderStyle = 4 'Fixed ToolWindow
Caption = "请选择进入系统的用户"
ClientHeight = 1980
ClientLeft = 2835
ClientTop = 3435
ClientWidth = 3705
Icon = "frmLogin.frx":0000
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 1169.849
ScaleMode = 0 'User
ScaleWidth = 3478.794
ShowInTaskbar = 0 'False
StartUpPosition = 2 '屏幕中心
Begin VB.ComboBox username
Height = 300
Left = 1320
TabIndex = 0
Top = 120
Width = 2325
End
Begin VB.CommandButton cmdOK
Caption = "确定"
Default = -1 'True
Height = 630
Left = 840
Picture = "frmLogin.frx":0442
Style = 1 'Graphical
TabIndex = 2
Top = 1200
Width = 540
End
Begin VB.CommandButton cmdCancel
Cancel = -1 'True
Caption = "取消"
Height = 630
Left = 2280
Picture = "frmLogin.frx":05CC
Style = 1 'Graphical
TabIndex = 3
Top = 1200
Width = 540
End
Begin VB.TextBox txtPassword
Height = 345
IMEMode = 3 'DISABLE
Left = 1290
PasswordChar = "*"
TabIndex = 1
Top = 645
Width = 2325
End
Begin VB.Label lblLabels
Caption = "用户名称(&U):"
Height = 270
Index = 0
Left = 105
TabIndex = 4
Top = 150
Width = 1080
End
Begin VB.Label lblLabels
Caption = "密 码(&P):"
Height = 270
Index = 1
Left = 105
TabIndex = 5
Top = 660
Width = 1080
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 rs As ADODB.Recordset
Public LoginSucceeded As Boolean
Private str As String
Private f As Integer
Private Sub cmdCancel_Click()
'设置全局变量为 false
'不提示失败的登录
LoginSucceeded = False
End
End Sub
Private Sub cmdOK_Click()
'检查正确的密码
LoginSucceeded = False
If username.Text = "" Or txtPassword.Text = "" Then
username.SetFocus
SendKeys "{Home}+{End}"
MsgBox "无效的用户名或密码,请重试!", , "登录"
Else
rs.Open "select name, password from password where name='" & Trim(Me.username) & "'", GetConnect, adOpenStatic, adLockReadOnly
If rs.EOF And rs.BOF Then
MsgBox "未找到此用户?", , "登录"
Else
str = rs![Password]
If Trim(str) = Trim(txtPassword.Text) Then
LoginSucceeded = True
Else
f = f + 1
MsgBox "第 " & f & " 密码错误?", , "登录"
If f = 3 Then
End
End If
End If
End If
rs.Close
If LoginSucceeded Then
Unload Me
FrmMain.Show
End If
End If
End Sub
Private Sub Form_Load()
Dim i As Integer
Set rs = New ADODB.Recordset
rs.Open "select name from password", GetConnect, adOpenStatic, adLockReadOnly
Do Until rs.EOF
Me.username.AddItem rs![Name]
rs.MoveNext
Loop
rs.Close
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -