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

📄 frmlogin.frm

📁 <Visual Basic 数据库开发实例精粹(第二版)>一书首先介绍了Visual Basic(简称VB)开发的技巧和重点技术
💻 FRM
字号:
VERSION 5.00
Begin VB.Form frmLogin 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "用户登录"
   ClientHeight    =   3570
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   5265
   LinkTopic       =   "Form1"
   LockControls    =   -1  'True
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   3570
   ScaleWidth      =   5265
   StartUpPosition =   2  '屏幕中心
   Begin VB.Frame Frame1 
      Height          =   3690
      Left            =   0
      TabIndex        =   4
      Top             =   -120
      Width           =   5265
      Begin VB.TextBox txt 
         Height          =   300
         Index           =   0
         Left            =   1545
         MaxLength       =   50
         TabIndex        =   0
         Text            =   "Admin"
         Top             =   1755
         Width           =   2175
      End
      Begin VB.TextBox txt 
         Height          =   300
         IMEMode         =   3  'DISABLE
         Index           =   1
         Left            =   1545
         MaxLength       =   50
         PasswordChar    =   "*"
         TabIndex        =   1
         Text            =   "Admin"
         Top             =   2220
         Width           =   2175
      End
      Begin VB.CommandButton cmdOK 
         Caption         =   "登录(&O)"
         Default         =   -1  'True
         Height          =   360
         Left            =   1200
         TabIndex        =   2
         Top             =   2850
         Width           =   1050
      End
      Begin VB.CommandButton cmdExit 
         Cancel          =   -1  'True
         Caption         =   "退出(&E)"
         Height          =   360
         Left            =   2445
         TabIndex        =   3
         Top             =   2850
         Width           =   1050
      End
      Begin VB.PictureBox picBG 
         Appearance      =   0  'Flat
         BackColor       =   &H00808080&
         BorderStyle     =   0  'None
         ForeColor       =   &H80000008&
         Height          =   1275
         Left            =   30
         ScaleHeight     =   1275
         ScaleWidth      =   5205
         TabIndex        =   5
         TabStop         =   0   'False
         Top             =   120
         Width           =   5205
         Begin VB.Label lblLogin 
            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
            Height          =   210
            Index           =   1
            Left            =   180
            TabIndex        =   9
            Top             =   165
            Width           =   900
         End
         Begin VB.Label lblLogin 
            AutoSize        =   -1  'True
            BackStyle       =   0  'Transparent
            Caption         =   "版权所有 (C) 2007-2008 特瑞飞软件"
            Height          =   180
            Index           =   2
            Left            =   2085
            TabIndex        =   8
            Top             =   1035
            Width           =   2970
         End
         Begin VB.Label lblLogin 
            AutoSize        =   -1  'True
            BackStyle       =   0  'Transparent
            Caption         =   "特瑞飞进销存管理系统 演示版"
            BeginProperty Font 
               Name            =   "宋体"
               Size            =   14.25
               Charset         =   134
               Weight          =   700
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            ForeColor       =   &H00FFFFFF&
            Height          =   285
            Index           =   3
            Left            =   600
            TabIndex        =   6
            Top             =   510
            Width           =   4065
         End
         Begin VB.Label lblLogin 
            AutoSize        =   -1  'True
            BackStyle       =   0  'Transparent
            Caption         =   "特瑞飞进销存管理系统 演示版"
            BeginProperty Font 
               Name            =   "宋体"
               Size            =   14.25
               Charset         =   134
               Weight          =   700
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            ForeColor       =   &H00000000&
            Height          =   285
            Index           =   0
            Left            =   645
            TabIndex        =   7
            Top             =   555
            Width           =   4065
         End
      End
      Begin VB.Label lblLogin 
         AutoSize        =   -1  'True
         BackStyle       =   0  'Transparent
         Caption         =   "用户名"
         Height          =   180
         Index           =   4
         Left            =   900
         TabIndex        =   12
         Top             =   1830
         Width           =   540
      End
      Begin VB.Label lblLogin 
         AutoSize        =   -1  'True
         BackStyle       =   0  'Transparent
         Caption         =   "登录密码"
         Height          =   180
         Index           =   5
         Left            =   720
         TabIndex        =   11
         Top             =   2280
         Width           =   720
      End
      Begin VB.Image Image1 
         Height          =   1305
         Left            =   3855
         Picture         =   "frmLogin.frx":0000
         Stretch         =   -1  'True
         Top             =   1665
         Width           =   1050
      End
      Begin VB.Label lblLogin 
         AutoSize        =   -1  'True
         BackStyle       =   0  'Transparent
         Caption         =   "注:默认登录用户:密码 是 Admin:Admin"
         ForeColor       =   &H00C00000&
         Height          =   180
         Index           =   6
         Left            =   960
         TabIndex        =   10
         Top             =   3435
         Width           =   3240
      End
   End
End
Attribute VB_Name = "frmLogin"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Private Sub cmdExit_Click()
  End
End Sub

Private Sub cmdOK_Click()
  Dim User As New clsUser     '用户对象
  Dim Result As gxcLoginResult   '登录结果(gxcLoginResult枚举类型)
  
  '用户登录并返回登录结果
  Result = User.IsValidUser(Trim(txt(0)), txt(1), UserID, TrueName, UserType)
  '合法用户
  If Result = ValidUser Then
     frmMain.Show
     Unload Me
  '用户名错误
  ElseIf Result = WrongUserName Then
     MsgBox "用户名错误!", vbInformation
     txt(0).SetFocus
  '密码错误
  ElseIf Result = WrongPassword Then
     MsgBox "密码错误!", vbInformation
     txt(1).SetFocus
  ElseIf Result = DBError Then
     MsgBox "数据库连接错误!", vbExclamation
  End If
End Sub

'文本框获得焦点时选中所有文字
Private Sub txt_GotFocus(Index As Integer)
  txt(Index).SelStart = 0                   '选中文字的起始位置
  txt(Index).SelLength = Len(txt(Index))    '选中文字的长度
End Sub

⌨️ 快捷键说明

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