📄 frmlogin.frm
字号:
VERSION 5.00
Begin VB.Form frmLogin
BorderStyle = 3 'Fixed Dialog
Caption = "login"
ClientHeight = 3060
ClientLeft = 2835
ClientTop = 3480
ClientWidth = 5550
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 1807.949
ScaleMode = 0 'User
ScaleWidth = 5211.149
ShowInTaskbar = 0 'False
StartUpPosition = 2 '屏幕中心
Begin VB.TextBox txtUserName
Height = 345
Left = 1920
TabIndex = 1
Top = 720
Width = 2325
End
Begin VB.CommandButton cmdOK
Caption = "&ok"
Default = -1 'True
Height = 390
Left = 1320
TabIndex = 4
Top = 2280
Width = 1140
End
Begin VB.CommandButton cmdCancel
Cancel = -1 'True
Caption = "&cancel"
Height = 390
Left = 3120
TabIndex = 5
Top = 2280
Width = 1140
End
Begin VB.TextBox txtPassword
Height = 345
IMEMode = 3 'DISABLE
Left = 1920
PasswordChar = "*"
TabIndex = 3
Top = 1440
Width = 2325
End
Begin VB.Label lblLabels
Caption = "&username:"
Height = 270
Index = 0
Left = 720
TabIndex = 0
Top = 840
Width = 1080
End
Begin VB.Label lblLabels
Caption = "&password:"
Height = 270
Index = 1
Left = 720
TabIndex = 2
Top = 1440
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
Public LoginSucceeded As Boolean
Public cn As New ADODB.Connection
Public rs As New ADODB.Recordset
Private Sub cmdCancel_Click()
'设置全局变量为 false
'不提示失败的登录
LoginSucceeded = False
Unload Me
End Sub
Private Sub cmdOK_Click()
'检查正确的密码
Set rs = New ADODB.Recordset
rs.Open "select * from users where username='" & txtUsername.Text & "' and password='" & txtPassword.Text & "'", cn, adOpenDynamic
If rs.EOF <> True Then
LoginSucceeded = True
rs.Close
cn.Close
Unload Me
frmMain.Show
Else
MsgBox "username or password is error,repeat it!", vbCritical, "Login"
txtUsername.SetFocus
SendKeys "{Home}+{End}"
rs.Close
End If
End Sub
Private Sub Form_Load()
strCn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=supplierDB.mdb;Persist Security Info=False"
Set cn = New ADODB.Connection
cn.Open strCn
End Sub
Private Sub txtPassword_gotfocus()
txtPassword.SelStart = 0
txtPassword.SelLength = Len(txtPassword.Text)
End Sub
Private Sub txtUsername_gotfocus()
txtUsername.SelStart = 0
txtUsername.SelLength = Len(txtUsername.Text)
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -