📄 frmlogin.frm
字号:
VERSION 5.00
Begin VB.Form FrmLogin
BackColor = &H00C0FFC0&
Caption = "系统登录"
ClientHeight = 2580
ClientLeft = 2850
ClientTop = 3495
ClientWidth = 5025
LinkTopic = "Frmlogin"
ScaleHeight = 2580
ScaleWidth = 5025
StartUpPosition = 1 '所有者中心
Begin VB.TextBox txtname
Height = 345
Left = 1920
TabIndex = 1
Top = 375
Width = 1965
End
Begin VB.CommandButton cmdOK
Caption = "确认登录"
Height = 390
Left = 840
MaskColor = &H00E0E0E0&
TabIndex = 4
Top = 1620
Width = 1140
End
Begin VB.CommandButton cmdCancel
Cancel = -1 'True
Caption = "取消登录"
Height = 390
Left = 2880
TabIndex = 5
Top = 1620
Width = 1140
End
Begin VB.TextBox txtpwd
Height = 345
IMEMode = 3 'DISABLE
Left = 1920
PasswordChar = "*"
TabIndex = 3
Top = 885
Width = 1965
End
Begin VB.Label lblLabels
AutoSize = -1 'True
BackColor = &H00C0FFC0&
Caption = "用户名称:"
Height = 180
Index = 0
Left = 960
TabIndex = 0
Top = 390
Width = 900
End
Begin VB.Label lblLabels
AutoSize = -1 'True
BackColor = &H00C0FFC0&
Caption = "密 码:"
Height = 180
Index = 1
Left = 960
TabIndex = 2
Top = 900
Width = 900
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 answer As String
Dim rs_login As New ADODB.Recordset
If Trim(txtname.Text) = "" Then '判断输入的用户名是否为空
answer = MsgBox("没有这个用户", vbYesNo + vbExclamation, "系统提示")
If answer = vbYes Then
txtpwd.Text = ""
txtname.SetFocus
Else
Unload Me
End If
Else
sql = "select * from 系统管理 where czyh='" & txtname.Text & "'"
rs_login.Open sql, conn, adOpenKeyset, adLockPessimistic
If rs_login.EOF = True Then
answer = MsgBox("没有这个用户", vbYesNo + vbExclamation, "系统提示")
If answer = vbYes Then
txtpwd.Text = ""
txtname.SetFocus
Else
Unload Me
End If
Else '检验密码是否正确
If Trim(rs_login.Fields(1)) = Trim(txtpwd.Text) Then
userID = txtname.Text
username = rs_login.Fields(2)
rs_login.Close
Unload Me
frmmain.Show
Else
answer = MsgBox("密码不正确", vbYesNo + vbExclamation, "系统提示")
If answer = vbYes Then
txtpwd.Text = ""
txtpwd.SetFocus
Else
Unload Me
End If
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 & "\house.mdb"
conn.Open connectionstring
cnt = 0
End Sub
Private Sub txtname_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
cmdOK.Default = True
txtpwd.SetFocus
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -