📄 login.frm
字号:
VERSION 5.00
Begin VB.Form login
Caption = "登录"
ClientHeight = 3975
ClientLeft = 60
ClientTop = 390
ClientWidth = 5565
LinkTopic = "Form2"
MaxButton = 0 'False
ScaleHeight = 3975
ScaleWidth = 5565
StartUpPosition = 2 '屏幕中心
Begin VB.CommandButton Command2
Caption = "取消"
Height = 615
Left = 2400
TabIndex = 5
Top = 2880
Width = 1455
End
Begin VB.CommandButton Command1
Caption = "确定"
Height = 615
Left = 960
TabIndex = 4
Top = 2880
Width = 1215
End
Begin VB.TextBox Text2
DataSource = "Adodc1"
Height = 615
IMEMode = 3 'DISABLE
Left = 2160
PasswordChar = "*"
TabIndex = 3
Top = 1800
Width = 1815
End
Begin VB.TextBox Text1
DataSource = "Adodc1"
Height = 615
Left = 2160
TabIndex = 2
Top = 960
Width = 1815
End
Begin VB.Label Label2
AutoSize = -1 'True
Caption = "密码"
Height = 540
Left = 960
TabIndex = 1
Top = 1920
Width = 840
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "用户名"
Height = 420
Left = 960
TabIndex = 0
Top = 1080
Width = 780
End
End
Attribute VB_Name = "login"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Public userID As String
Public userpow As String
Dim cnt As Integer
Private Sub Command1_Click()
Dim sql As String
Dim rs_login As New ADODB.Recordset
Dim conn As New ADODB.Connection
conn.Open "provider=Microsoft.Jet.OLEDB.4.0; data source=" & App.Path & "\database1.mdb"
If Trim(Text1.Text) = "" Then
MsgBox "用户名不能为空,请重新输入!"
Text1.SetFocus
Else
sql = "select * from 系统信息表 where 用户名='" & Trim(Text1.Text) & "'"
rs_login.Open sql, conn, adOpenKeyset, adLockPessimistic
If rs_login.EOF = True Then
MsgBox "没有这个用户,请重输入!", vbOKOnly + vbExclamation, ""
Text1.Text = ""
Text1.SetFocus
Else
userID = Text1.Text
If Trim(rs_login.Fields(1)) = Trim(Text2.Text) Then
Unload Me
Form1.Show
Else
MsgBox "密码不正确,请重输入!", vbOKOnly + vbExclamation, ""
Text2.SetFocus
Text2.Text = ""
End If
End If
End If
cnt = cnt + 1
If cnt = 3 Then
Unload Me
End If
Exit Sub
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
Private Sub Form_Load()
cnt = 0
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -