⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 frmcheck.frm

📁 图书馆管理系统 VB制作 用户名admin和密码123456
💻 FRM
字号:
VERSION 5.00
Begin VB.Form frmcheck 
   Caption         =   "欢迎登录图书馆"
   ClientHeight    =   2385
   ClientLeft      =   60
   ClientTop       =   450
   ClientWidth     =   4140
   ControlBox      =   0   'False
   Icon            =   "frmcheck.frx":0000
   LinkTopic       =   "Form1"
   LockControls    =   -1  'True
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   2385
   ScaleWidth      =   4140
   StartUpPosition =   3  '窗口缺省
   Begin VB.CommandButton cmdexit 
      Caption         =   "取消"
      Height          =   375
      Left            =   2160
      TabIndex        =   6
      Top             =   1800
      Width           =   1215
   End
   Begin VB.CommandButton cmdlogin 
      Caption         =   "登录 "
      Default         =   -1  'True
      Height          =   375
      Left            =   480
      TabIndex        =   5
      Top             =   1800
      Width           =   1215
   End
   Begin VB.TextBox txtPassword 
      Height          =   375
      IMEMode         =   3  'DISABLE
      Left            =   1920
      PasswordChar    =   "*"
      TabIndex        =   4
      Top             =   1200
      Width           =   2055
   End
   Begin VB.TextBox txtUsername 
      Height          =   375
      Left            =   1920
      TabIndex        =   3
      Top             =   720
      Width           =   2055
   End
   Begin VB.Label lblPassword 
      Alignment       =   2  'Center
      Caption         =   "密    码:"
      BeginProperty Font 
         Name            =   "楷体_GB2312"
         Size            =   10.5
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Left            =   480
      TabIndex        =   2
      Top             =   1200
      Width           =   1335
   End
   Begin VB.Label lbltitle 
      Alignment       =   2  'Center
      Caption         =   "请填写用户名和密码"
      BeginProperty Font 
         Name            =   "楷体_GB2312"
         Size            =   15.75
         Charset         =   134
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   0
      TabIndex        =   1
      Top             =   120
      Width           =   3975
   End
   Begin VB.Label lblUsername 
      Alignment       =   2  'Center
      Caption         =   "用 户 名:"
      BeginProperty Font 
         Name            =   "楷体_GB2312"
         Size            =   10.5
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Left            =   600
      TabIndex        =   0
      Top             =   720
      Width           =   1095
   End
End
Attribute VB_Name = "frmcheck"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub cmdlogin_Click()
    If checkform = False Then      '对输入内容进行判断,如果不符合要求则不能登录
        Exit Sub
    End If
    Dim strUsername, strPassword, strsql, strconn As String
    strUsername = Trim(txtUsername.Text)
    strPassword = Trim(txtPassword.Text)
    strconn = "Provider=Microsoft.Jet.OLEDB.4.0;Data source=" & _
    App.Path & "\test.mdb;Persist Security Info=False"                  '连接access数据库
    Dim conn As New ADODB.Connection
    Dim rs As New ADODB.Recordset
    conn.ConnectionString = strconn
    conn.Open
    strsql = "Select Top 1 Username,Password From [User] WHERE Username= '" & strUsername & "'"
    rs.Open strsql, conn, 1, 1     '对输入内容与数据库中的数据进行比较
    If rs.RecordCount = 0 Then
        MsgBox "该用户不存在,请核对!"
        txtUsername.Text = ""
        txtUsername.SetFocus
    Else
        If rs("Password") = strPassword Then
            MsgBox "成功登录!"
            frmmain.Show
            frmmain.mnulogin.Enabled = False
            frmmain.mnuaction.Enabled = True
            frmcheck.Hide
        Else
            MsgBox "密码错误!"
            txtPassword.Text = ""
            txtPassword.SetFocus
        End If
    End If
    rs.Close
    conn.Close
    Set rs = Nothing
    Set conn = Nothing
End Sub
Private Function checkform() As Boolean
    Dim strUsername, strPassword
    strUsername = Trim(txtUsername.Text)
    strPassword = Trim(txtPassword.Text)
    If strUsername = "" Then
        MsgBox "用户名不能为空,请输入用户名!"      '判断用户名是否为空
        txtUsername.SetFocus
        checkform = False
        Exit Function
   End If
   If strPassword = "" Then
        MsgBox "密码不能为空,请输入密码!"          '判断密码是否为空
        txtPassword.SetFocus
        checkform = False
        Exit Function
   End If
   checkform = True
   End Function

Private Sub cmdexit_Click()
  frmmain.Show
  frmcheck.Hide
End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -