📄 frmlogin.frm
字号:
VERSION 5.00
Begin VB.Form frmLogin
AutoRedraw = -1 'True
BackColor = &H00C0C0C0&
Caption = "登录窗口"
ClientHeight = 2145
ClientLeft = 2850
ClientTop = 3495
ClientWidth = 4530
Icon = "frmLogin.frx":0000
LinkTopic = "Form1"
LockControls = -1 'True
MaxButton = 0 'False
Picture = "frmLogin.frx":0442
ScaleHeight = 1267.335
ScaleMode = 0 'User
ScaleWidth = 4253.425
StartUpPosition = 2 '屏幕中心
Begin VB.PictureBox Picture1
AutoRedraw = -1 'True
AutoSize = -1 'True
BackColor = &H00FFFFC0&
BorderStyle = 0 'None
Height = 240
Index = 1
Left = 345
Picture = "frmLogin.frx":73B7
ScaleHeight = 240
ScaleWidth = 240
TabIndex = 7
Top = 330
Width = 240
End
Begin VB.ComboBox UserTxt
Appearance = 0 'Flat
BackColor = &H00FFFFFF&
ForeColor = &H00000000&
Height = 300
Left = 1650
TabIndex = 1
Text = "UserTxt"
Top = 330
Width = 2325
End
Begin VB.PictureBox Picture1
AutoRedraw = -1 'True
AutoSize = -1 'True
BackColor = &H00FFFF80&
BorderStyle = 0 'None
Height = 240
Index = 0
Left = 495
Picture = "frmLogin.frx":7501
ScaleHeight = 240
ScaleWidth = 240
TabIndex = 6
Top = 735
Width = 240
End
Begin VB.CommandButton cmdOK
Caption = "确定(O)"
Default = -1 'True
Height = 375
Left = 840
Style = 1 'Graphical
TabIndex = 2
Top = 1440
Width = 1215
End
Begin VB.CommandButton cmdCancel
Cancel = -1 'True
Caption = "取消(&C)"
Height = 375
Left = 2520
Style = 1 'Graphical
TabIndex = 3
Top = 1440
Width = 1215
End
Begin VB.TextBox txtPassword
BackColor = &H00FFFFFF&
ForeColor = &H00000000&
Height = 270
IMEMode = 3 'DISABLE
Left = 1650
PasswordChar = "*"
TabIndex = 0
Top = 750
Width = 2325
End
Begin VB.Label lblLabels
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "用户名(&U):"
Height = 180
Index = 0
Left = 630
TabIndex = 4
Top = 390
Width = 900
End
Begin VB.Label lblLabels
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "密码(&P):"
Height = 180
Index = 1
Left = 795
TabIndex = 5
Top = 765
Width = 720
End
End
Attribute VB_Name = "frmLogin"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim LOGINNO As Integer '登录次数
Dim PassYu(30) As String, strPurView(30) As String '存储密码和权限
Private Sub cmdCancel_Click()
Unload Me
End Sub
Private Sub cmdOK_Click()
'检查密码的正确性
Dim X As Long
X = UserTxt.ListIndex
If txtPassword.Text = PassYu(X) Then
UserText = UserTxt.Text
PurView = strPurView(X)
'密码正确时
frmLogin.MousePointer = 11
Unload Me
frmSplash.Show
Exit Sub
Else
MsgBox "无效的密码,再试一次!", 32, "登录"
LOGINNO = LOGINNO + 1
If LOGINNO > 3 Then
MsgBox "对不起,您不能使用该系统!", 64, "登录失败"
Unload Me
Exit Sub
End If
txtPassword.SetFocus
SendKeys "{Home}+{End}"
End If
End Sub
Private Sub Form_Load()
On Error Resume Next
Dim strRst As Recordset
Dim strQry As String
Dim X, i As Long
Call checkPath
Dim UserYu(10) As String
strQry = "select * from userS"
Set strRst = New Recordset
strRst.Open strQry, Conn, adOpenKeyset, adLockOptimistic
If Not strRst.EOF And Not strRst.BOF Then
X = strRst.RecordCount
For i = 0 To X - 1
UserYu(i) = strRst.Fields(0).Value
If Not IsNull(strRst.Fields(1).Value) Then
PassYu(i) = strRst.Fields(1).Value
End If
If Not IsNull(strRst.Fields(2).Value) Then
strPurView(i) = strRst.Fields(2).Value
End If
UserTxt.AddItem UserYu(i), i
strRst.MoveNext
Next
Else
Unload Me
End If
strRst.Close
Set strRst = Nothing
If X >= 1 Then
UserTxt.ListIndex = 0
End If
LOGINNO = 1
End Sub
Private Sub UserTxt_Click()
SendKeys "{Tab}"
End Sub
Private Sub UserTxt_LostFocus()
txtPassword.SetFocus
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -