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

📄 登录界面.frm

📁 vb manange system 看看就行
💻 FRM
字号:
VERSION 5.00
Begin VB.Form frmLogin 
   BorderStyle     =   3  'Fixed Dialog
   Caption         =   "系统登录"
   ClientHeight    =   5835
   ClientLeft      =   2850
   ClientTop       =   2085
   ClientWidth     =   6435
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   3447.511
   ScaleMode       =   0  'User
   ScaleWidth      =   6042.118
   ShowInTaskbar   =   0   'False
   Begin VB.Data Data1 
      Caption         =   "Data1"
      Connect         =   "Access"
      DatabaseName    =   "系统数据库.mdb"
      DefaultCursorType=   0  '缺省游标
      DefaultType     =   2  '使用 ODBC
      Exclusive       =   0   'False
      Height          =   345
      Left            =   2400
      Options         =   0
      ReadOnly        =   0   'False
      RecordsetType   =   1  'Dynaset
      RecordSource    =   "登录信息"
      Top             =   3840
      Visible         =   0   'False
      Width           =   1980
   End
   Begin VB.ComboBox Combo1 
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   12
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   360
      ItemData        =   "登录界面.frx":0000
      Left            =   2880
      List            =   "登录界面.frx":000A
      TabIndex        =   6
      Text            =   "请选择"
      Top             =   720
      Width           =   2295
   End
   Begin VB.TextBox txtUserName 
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   12
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   585
      Left            =   2880
      TabIndex        =   1
      Top             =   1560
      Width           =   2325
   End
   Begin VB.CommandButton cmdOK 
      Caption         =   "登录系统"
      Default         =   -1  'True
      Height          =   495
      Left            =   1320
      TabIndex        =   4
      Top             =   4560
      Width           =   1215
   End
   Begin VB.CommandButton cmdCancel 
      Cancel          =   -1  'True
      Caption         =   "退出登录"
      Height          =   495
      Left            =   3840
      TabIndex        =   5
      Top             =   4560
      Width           =   1335
   End
   Begin VB.TextBox txtPassword 
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   12
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   555
      IMEMode         =   3  'DISABLE
      Left            =   2880
      PasswordChar    =   "*"
      TabIndex        =   3
      Top             =   2640
      Width           =   2325
   End
   Begin VB.Label Label1 
      AutoSize        =   -1  'True
      Caption         =   "用户类别(&c):"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   12
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   240
      Left            =   1440
      TabIndex        =   7
      Top             =   720
      Width           =   1560
   End
   Begin VB.Label lblLabels 
      AutoSize        =   -1  'True
      Caption         =   "用户名称(&U):"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   12
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   240
      Index           =   0
      Left            =   1440
      TabIndex        =   0
      Top             =   1710
      Width           =   1560
   End
   Begin VB.Label lblLabels 
      AutoSize        =   -1  'True
      Caption         =   "密    码(&P):"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   12
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   240
      Index           =   1
      Left            =   1425
      TabIndex        =   2
      Top             =   2700
      Width           =   1560
   End
End
Attribute VB_Name = "frmLogin"
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()
    '设置全局变量为 false
    '不提示失败的登录
  LoginSucceeded = False
  Unload Me
  frmAbout.Show
End Sub

Private Sub cmdOK_Click()
    '检查正确的密码
    Dim db As Database, i, g As Long, rs As Recordset
     Set db = OpenDatabase(App.Path + "/系统数据库.mdb")
     Set rs = db.OpenRecordset("登录信息", dbOpenTable)
         g = rs.RecordCount
         rs.MoveFirst
     For i = 0 To g - 1
      If Combo1.ListIndex = rs.Fields(2).Value Then
       If txtUserName.Text = rs.Fields(0).Value Then
        If txtPassword.Text = rs.Fields(1).Value Then
        '将代码放在这里传递
        '成功到 calling 函数
        '设置全局变量时最容易的
        LoginSucceeded = True
        Form2.Show
        i = g + 1
        Me.Hide
      Else
        MsgBox "无效的密码,请重试!", , "登录"
        rs.MoveNext
        txtPassword.SetFocus
        SendKeys "{Home}+{End}"
      End If
    Else
        rs.MoveNext
    End If
    Else
    rs.MoveNext
    End If
    Next i
    If i = g Then
    MsgBox "无此用户", vbExclamation + vbOKOnly, "注意"
    txtUserName.Text = ""
    txtPassword.Text = ""
    txtUserName.SetFocus
    End If
    rs.Close
End Sub

⌨️ 快捷键说明

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