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

📄 frmlogin.frm

📁 一个比较适合做毕业设计的程序
💻 FRM
字号:
VERSION 5.00
Begin VB.Form DlgLogin 
   BackColor       =   &H00C0FFFF&
   BorderStyle     =   3  'Fixed Dialog
   Caption         =   "登陆"
   ClientHeight    =   2580
   ClientLeft      =   3630
   ClientTop       =   2355
   ClientWidth     =   4575
   Icon            =   "frmLogin.frx":0000
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   1524.349
   ScaleMode       =   0  'User
   ScaleWidth      =   4295.677
   ShowInTaskbar   =   0   'False
   Begin VB.CommandButton cmdCancel 
      Height          =   300
      Left            =   2280
      Picture         =   "frmLogin.frx":058A
      Style           =   1  'Graphical
      TabIndex        =   5
      Top             =   2040
      Width           =   1095
   End
   Begin VB.CommandButton cmdOK 
      Height          =   300
      Left            =   720
      Picture         =   "frmLogin.frx":0AE5
      Style           =   1  'Graphical
      TabIndex        =   4
      Top             =   2040
      Width           =   1095
   End
   Begin VB.TextBox txtUserName 
      BackColor       =   &H00C0FFC0&
      Height          =   405
      Left            =   1560
      TabIndex        =   0
      Top             =   720
      Width           =   1845
   End
   Begin VB.TextBox txtPassword 
      BackColor       =   &H00C0FFC0&
      Height          =   405
      IMEMode         =   3  'DISABLE
      Left            =   1560
      PasswordChar    =   "*"
      TabIndex        =   1
      Top             =   1320
      Width           =   1845
   End
   Begin VB.Image Image1 
      Height          =   480
      Index           =   1
      Left            =   120
      Picture         =   "frmLogin.frx":10BC
      Top             =   0
      Width           =   480
   End
   Begin VB.Label lblLabels 
      AutoSize        =   -1  'True
      BackStyle       =   0  'Transparent
      Caption         =   "密  码:"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   10.5
         Charset         =   134
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00FF0000&
      Height          =   210
      Index           =   3
      Left            =   480
      TabIndex        =   3
      Top             =   1440
      Width           =   930
   End
   Begin VB.Label lblLabels 
      AutoSize        =   -1  'True
      BackStyle       =   0  'Transparent
      Caption         =   "用户名:"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   10.5
         Charset         =   134
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00FF0000&
      Height          =   210
      Index           =   2
      Left            =   480
      TabIndex        =   2
      Top             =   840
      Width           =   915
   End
   Begin VB.Image Image1 
      Height          =   480
      Index           =   0
      Left            =   3720
      Picture         =   "frmLogin.frx":14FE
      Top             =   960
      Width           =   480
   End
   Begin VB.Image Image2 
      Height          =   3015
      Left            =   0
      Picture         =   "frmLogin.frx":1940
      Top             =   0
      Width           =   4905
   End
End
Attribute VB_Name = "DlgLogin"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Public LoginSucceeded As Boolean

Private Sub cmdCancel_Click()
    'set the global var to false
    'to denote a failed login
    LoginSucceeded = False
    Unload Me
End Sub

Private Sub cmdOK_Click()
On Error GoTo errh:
    Dim rs As ADODB.Recordset
    Set rs = New ADODB.Recordset
    Set rs = cn.Execute("SELECT UserName , Password  FROM 超级用户 ")
    If rs.EOF Then
        rs.Close
        Set rs = Nothing
        Unload Me
        Load FrmMain
        Exit Sub
    End If
    rs.MoveFirst
    Dim i As Integer
    '校验是否为超级用户
    Do
        If rs.Fields("UserName") = txtUserName.Text Then
            If rs.Fields("Password") = txtPassword.Text Then
                UserType = True
                LoginSucceeded = True
                rs.Close
                If txtPassword.Text = "Admin" Then IsAdmin = True
                Unload Me
                Load FrmMain
                Exit Sub
                Exit Do
            End If
        End If
        rs.MoveNext
    Loop Until rs.EOF
    '校验是否为普通用户
    Set rs = cn.Execute("SELECT 学号 FROM 学生 WHERE 学号 =" & "'" & txtPassword.Text & "'")
    If rs.EOF Then
        MsgBox "无效密码或用户名请重试!", , "Login"
        txtPassword.SetFocus
        SendKeys "{Home}+{End}"
    Else
        rs.Close
        UserType = False
        LoginSucceeded = True
        Unload Me
        Load FrmMain
    End If
    Exit Sub
errh:
    MsgBox Err.Description
End Sub

Private Sub Form_Load()
    Dim s As String
    MakeCenter DlgLogin
    s = MakeConnection() '创建全局ADO连接
    If s <> "OK" Then
        MsgBox s, , "错误!"
        Unload Me
        LoginSucceeded = False
    End If
End Sub

Private Sub Form_Unload(Cancel As Integer)
    If Not LoginSucceeded Then '如果登陆失败
        cn.Close '释放连接
        Set cn = Nothing
    End If
End Sub

Private Sub Image2_Click()

End Sub

⌨️ 快捷键说明

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