📄 login.frm
字号:
VERSION 5.00
Begin VB.Form Form3
Caption = "登录"
ClientHeight = 3195
ClientLeft = 60
ClientTop = 345
ClientWidth = 4680
LinkTopic = "Form3"
MaxButton = 0 'False
ScaleHeight = 3195
ScaleWidth = 4680
StartUpPosition = 2 'CenterScreen
Begin VB.CommandButton Command2
Caption = "取消"
Height = 375
Left = 2520
TabIndex = 5
Top = 1920
Width = 975
End
Begin VB.CommandButton Command1
Caption = "登录"
Height = 375
Left = 720
TabIndex = 4
Top = 1920
Width = 975
End
Begin VB.TextBox Text2
Height = 285
IMEMode = 3 'DISABLE
Left = 1560
PasswordChar = "*"
TabIndex = 3
Top = 1200
Width = 1695
End
Begin VB.TextBox Text1
Height = 285
Left = 1560
TabIndex = 2
Top = 720
Width = 1695
End
Begin VB.Label Label2
AutoSize = -1 'True
Caption = "密 码"
Height = 195
Left = 840
TabIndex = 1
Top = 1200
Width = 495
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "用户名 "
Height = 195
Left = 840
TabIndex = 0
Top = 720
Width = 630
End
End
Attribute VB_Name = "Form3"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim cnt As Integer '记录确定次数
Private Sub Command1_Click()
Dim sql As String
Dim rs_login As New ADODB.Recordset
If Trim(Text1.Text) = "" Then '判断输入的用户名是否为空
MsgBox "没有这个用户", vbOKOnly + vbExclamation, ""
Text1.SetFocus
Else
sql = "select * from 系统信息 where user_ID='" & Text1.Text & "'"
rs_login.Open sql, conn, adOpenKeyset, adLockPessimistic
If rs_login.EOF = True Then
MsgBox "没有这个用户", vbOKOnly + vbExclamation, ""
Text1.SetFocus
Else '检验密码是否正确
If Trim(rs_login.Fields(1)) = Trim(Text2.Text) Then
userID = Text1.Text
username = rs_login.Fields(2)
rs_login.Close
Unload Me
frmmain.Show
Else
MsgBox "密码不正确", vbOKOnly + vbExclamation, ""
Text2.SetFocus
End If
End If
End If
cnt = cnt + 1
If cnt = 3 Then
Unload Me
End If
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
Private Sub Form_Load()
Dim connectionstring As String
connectionstring = "provider=Microsoft.Jet.oledb.3.51;" & _
"data source=archive1.mdb"
conn.Open connectionstring
cnt = 0
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -