📄 frmlogin.frm
字号:
VERSION 5.00
Begin VB.Form frmlogin
BackColor = &H0080FFFF&
Caption = "登录"
ClientHeight = 4500
ClientLeft = 60
ClientTop = 450
ClientWidth = 5760
LinkTopic = "Form1"
MaxButton = 0 'False
ScaleHeight = 4500
ScaleWidth = 5760
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton cmdcancel
Caption = "取消"
Height = 495
Left = 3000
TabIndex = 5
Top = 3000
Width = 1215
End
Begin VB.CommandButton cmdok
Caption = "确定"
Height = 495
Left = 720
TabIndex = 4
Top = 3000
Width = 1215
End
Begin VB.TextBox txtpwd
Height = 495
Left = 2040
TabIndex = 3
Top = 1800
Width = 1695
End
Begin VB.TextBox txtname
Height = 495
Left = 2040
TabIndex = 2
Top = 960
Width = 1695
End
Begin VB.Label Label2
AutoSize = -1 'True
BackColor = &H0080FFFF&
Caption = "密码"
Height = 180
Left = 1320
TabIndex = 1
Top = 1800
Width = 360
End
Begin VB.Label Label1
AutoSize = -1 'True
BackColor = &H0080FFFF&
Caption = "用户名"
Height = 180
Left = 1200
TabIndex = 0
Top = 960
Width = 540
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 cnt As Integer '记录确定次数
Private Sub cmdcancel_Click()
conn.Close
Set conn = Nothing
End
End Sub
Private Sub cmdok_Click()
Dim sql As String
Dim rs_login As New ADODB.Recordset
If Trim(txtname.Text) = "" Then '判断输入的用户名是否为空
MsgBox "没有这个用户", vbOKOnly + vbExclamation, ""
txtname.SetFocus
Else
sql = "select * from 系统管理 where 用户名='" & txtname.Text & "'"
rs_login.Open sql, conn, adOpenKeyset, adLockPessimistic
If rs_login.EOF = True Then
MsgBox "没有这个用户", vbOKOnly + vbExclamation, ""
txtname.SetFocus
Else '检验密码是否正确
If Trim(rs_login.Fields(1)) = Trim(txtpwd.Text) Then
userID = txtname.Text
username = rs_login.Fields(2)
rs_login.Close
Unload Me
MDIForm1.Show
Else
MsgBox "密码不正确", vbOKOnly + vbExclamation, ""
txtpwd.SetFocus
End If
End If
End If
cnt = cnt + 1
If cnt = 3 Then
Unload Me
End If
End Sub
Private Sub Form_Load()
Dim connectionstring As String
connectionstring = "provider=Microsoft.Jet.oledb.4.0;" & _
"data source= " & App.Path & "\zhongjie.mdb"
conn.Open connectionstring
cnt = 0
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -