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

📄 frmlogin.frm

📁 vb试卷生成系统!能够生成8开vb考试试卷
💻 FRM
字号:
VERSION 5.00
Begin VB.Form frmLogin 
   BorderStyle     =   3  'Fixed Dialog
   Caption         =   "登录"
   ClientHeight    =   2055
   ClientLeft      =   2835
   ClientTop       =   3480
   ClientWidth     =   4125
   Icon            =   "frmLogin.frx":0000
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   1214.162
   ScaleMode       =   0  'User
   ScaleWidth      =   3873.152
   ShowInTaskbar   =   0   'False
   StartUpPosition =   2  '屏幕中心
   Begin VB.PictureBox PicCaption 
      AutoRedraw      =   -1  'True
      AutoSize        =   -1  'True
      BorderStyle     =   0  'None
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   720
      Left            =   0
      Picture         =   "frmLogin.frx":0442
      ScaleHeight     =   720
      ScaleWidth      =   9600
      TabIndex        =   17
      TabStop         =   0   'False
      Top             =   3420
      Visible         =   0   'False
      Width           =   9600
      Begin VB.PictureBox PicBorder 
         AutoRedraw      =   -1  'True
         AutoSize        =   -1  'True
         BorderStyle     =   0  'None
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   150
         Left            =   0
         Picture         =   "frmLogin.frx":16C86
         ScaleHeight     =   150
         ScaleWidth      =   1050
         TabIndex        =   18
         TabStop         =   0   'False
         Top             =   0
         Visible         =   0   'False
         Width           =   1050
      End
   End
   Begin VB.CommandButton Command5 
      BackColor       =   &H00C0C0C0&
      Caption         =   "删除用户"
      Height          =   390
      Left            =   2970
      Style           =   1  'Graphical
      TabIndex        =   14
      Top             =   2040
      Width           =   900
   End
   Begin VB.CommandButton Command4 
      BackColor       =   &H00C0C0C0&
      Caption         =   "取消"
      Height          =   390
      Left            =   2070
      Style           =   1  'Graphical
      TabIndex        =   13
      Top             =   2040
      Width           =   900
   End
   Begin VB.TextBox Text4 
      Height          =   345
      IMEMode         =   3  'DISABLE
      Left            =   1290
      PasswordChar    =   "*"
      TabIndex        =   11
      Top             =   1560
      Width           =   2565
   End
   Begin VB.CommandButton Command3 
      BackColor       =   &H00C0C0C0&
      Caption         =   "确定"
      Height          =   390
      Left            =   1170
      Style           =   1  'Graphical
      TabIndex        =   12
      Top             =   2040
      Width           =   900
   End
   Begin VB.CommandButton Command2 
      BackColor       =   &H00C0C0C0&
      Caption         =   "修改密码"
      Height          =   390
      Left            =   2880
      Style           =   1  'Graphical
      TabIndex        =   7
      Top             =   1050
      Width           =   900
   End
   Begin VB.CommandButton Command1 
      BackColor       =   &H00C0C0C0&
      Caption         =   "添加用户"
      Enabled         =   0   'False
      Height          =   390
      Left            =   1980
      Style           =   1  'Graphical
      TabIndex        =   6
      Top             =   1050
      Width           =   900
   End
   Begin VB.Data Data1 
      Caption         =   "Data1"
      Connect         =   "Access"
      DatabaseName    =   ""
      DefaultCursorType=   0  '缺省游标
      DefaultType     =   2  '使用 ODBC
      Exclusive       =   0   'False
      Height          =   435
      Left            =   720
      Options         =   0
      ReadOnly        =   0   'False
      RecordsetType   =   1  'Dynaset
      RecordSource    =   "login"
      Top             =   2730
      Visible         =   0   'False
      Width           =   2565
   End
   Begin VB.TextBox txtUserName 
      Height          =   345
      Left            =   1290
      TabIndex        =   1
      Top             =   90
      Width           =   2565
   End
   Begin VB.CommandButton cmdOK 
      BackColor       =   &H00C0C0C0&
      Caption         =   "登入系统"
      Height          =   390
      Left            =   180
      Style           =   1  'Graphical
      TabIndex        =   4
      ToolTipText     =   "以用户名和密码登录"
      Top             =   1050
      Width           =   900
   End
   Begin VB.CommandButton cmdCancel 
      BackColor       =   &H00C0C0C0&
      Cancel          =   -1  'True
      Caption         =   "取消登录"
      Height          =   390
      Left            =   1080
      Style           =   1  'Graphical
      TabIndex        =   5
      ToolTipText     =   "取消登录退出"
      Top             =   1050
      Width           =   900
   End
   Begin VB.TextBox txtPassword 
      Height          =   345
      IMEMode         =   3  'DISABLE
      Left            =   1290
      PasswordChar    =   "*"
      TabIndex        =   3
      Top             =   570
      Width           =   2565
   End
   Begin VB.TextBox Text1 
      DataField       =   "user"
      DataSource      =   "Data1"
      Height          =   345
      Left            =   1290
      Locked          =   -1  'True
      TabIndex        =   15
      TabStop         =   0   'False
      Top             =   90
      Width           =   2325
   End
   Begin VB.TextBox Text2 
      DataField       =   "pasw"
      DataSource      =   "Data1"
      Height          =   345
      Left            =   1290
      Locked          =   -1  'True
      TabIndex        =   16
      TabStop         =   0   'False
      Top             =   570
      Width           =   2325
   End
   Begin VB.TextBox Text3 
      Height          =   345
      IMEMode         =   3  'DISABLE
      Left            =   1290
      PasswordChar    =   "*"
      TabIndex        =   9
      Top             =   1050
      Visible         =   0   'False
      Width           =   2565
   End
   Begin VB.Label lblLabels 
      BackStyle       =   0  'Transparent
      Caption         =   "用户名称(&U):"
      Height          =   270
      Index           =   0
      Left            =   105
      TabIndex        =   0
      Top             =   180
      Width           =   1080
   End
   Begin VB.Label lblLabels 
      BackStyle       =   0  'Transparent
      Caption         =   "新密码(&N):"
      Height          =   270
      Index           =   2
      Left            =   105
      TabIndex        =   8
      Top             =   1110
      Visible         =   0   'False
      Width           =   1080
   End
   Begin VB.Label lblLabels 
      BackStyle       =   0  'Transparent
      Caption         =   "密码(&P):"
      Height          =   270
      Index           =   1
      Left            =   105
      TabIndex        =   2
      Top             =   630
      Width           =   1080
   End
   Begin VB.Label lblLabels 
      BackStyle       =   0  'Transparent
      Caption         =   "密码确认(&R):"
      Height          =   270
      Index           =   3
      Left            =   120
      TabIndex        =   10
      Top             =   1620
      Width           =   1080
   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 m_cN As cNeoCaption
Public presskey As String
Public Loginnum, loginnum1 As Integer
Private Sub cmdCancel_Click()
    End
End Sub
Private Sub cmdOK_Click()
Data1.Recordset.MoveFirst
Dim continue As Boolean
continue = True
Do While Text1.Text <> "" And continue
    If Text1.Text = txtUserName.Text And Text2.Text = txtPassword.Text Then
        continue = False
        Command1.Enabled = True
        Me.Hide
        frmSplash.Show
    Else
        Data1.Recordset.MoveNext
        If Data1.Recordset.EOF Then
            Loginnum = Loginnum + 1
            MsgBox "无效的用户名或密码,请重试!", , "登录"
            txtUserName.SetFocus
            SendKeys "{Home}+{End}"
            If Loginnum = 3 Then
                MsgBox "你已经尝试了太多次,无法登陆,请找管理员联系!", , "关闭"
                End
            End If
        End If
    End If
Loop
End Sub

Private Sub Command1_Click()
presskey = "添加用户"
cmdOK.Visible = False
cmdCancel.Visible = False
Command1.Visible = False
Command2.Visible = False
lblLabels(3).Visible = True
Text4.Visible = True
lblLabels(3).top = lblLabels(2).top
Text4.top = Text3.top
Command3.top = 921
Command4.top = 921
Command5.top = 921
Me.Height = 3000
Loginnum = 0
txtUserName.SetFocus
End Sub

Private Sub Command2_Click()
presskey = "修改密码"
cmdOK.Visible = False
cmdCancel.Visible = False
Command1.Visible = False
Command2.Visible = False
lblLabels(2).Visible = True
Text3.Visible = True
Me.Height = 3500
loginnum1 = 0
txtUserName.SetFocus
End Sub
Private Sub Command3_Click()
    Data1.Recordset.MoveFirst
    Dim continue As Boolean
    continue = True
    If presskey = "添加用户" Then
        If txtPassword.Text <> Text4.Text Then
            MsgBox "两次输入密码不同!请重试!", , "登录"
            continue = False
        End If
    Else
        If Text3.Text <> Text4.Text Then
            MsgBox "两次输入密码不同!请重试!", , "登录"
            continue = False
        End If
    End If
    Do While Text1.Text <> "" And continue
        If Text1.Text = txtUserName.Text And presskey = "添加用户" Then
            continue = False
            MsgBox "该用户已存在,添加失败!", , "添加"
        
        ElseIf Text1.Text = txtUserName.Text And Text2.Text = txtPassword.Text Then
            continue = False
            If presskey = "添加用户" Then
            Else
                Text2.Text = Text3.Text
                Data1.Recordset.MoveFirst
                huifu
            End If
        Else
            Data1.Recordset.MoveNext
            If Data1.Recordset.EOF Then
                If presskey = "添加用户" Then
                    Data1.Recordset.AddNew
                    Text1.Text = txtUserName.Text
                    Text2.Text = txtPassword.Text
                    Data1.Recordset.MoveFirst
                    MsgBox "新用户添加成功!", , "添加"
                    continue = False
                    huifu
                Else
                    loginnum1 = loginnum1 + 1
                    MsgBox "无效的用户名或密码,请重试!", , "登录"
                    txtUserName.SetFocus
                    SendKeys "{Home}+{End}"
                    If loginnum1 = 3 Then
                        MsgBox "你已经尝试了太多次,无法登陆,请找管理员联系!", , "关闭"
                        End
                    End If
                End If
            End If
        End If
    Loop
End Sub

Private Sub Command4_Click()
huifu
End Sub

Private Sub Command5_Click()
    Data1.Recordset.MoveFirst
    Dim continue As Boolean
    continue = True
    Do While Text1.Text <> "" And continue
        If Text1.Text = txtUserName.Text And Text2.Text = txtPassword.Text Then
            continue = False
            Dim a As Integer
            a = MsgBox("找到对应用户,确认删除该记录么?", vbOK, "确认?")
            If a = 1 And Data1.Recordset.RecordCount > 1 Then
                Data1.Recordset.Delete
                MsgBox "该用户已被删除!", , "成功删除"
                Data1.Recordset.MoveFirst
                huifu
            End If
        Else
            Data1.Recordset.MoveNext
            If Data1.Recordset.EOF Then
                loginnum1 = loginnum1 + 1
                MsgBox "无效的用户名或密码,请重试!", , "登录"
                txtUserName.SetFocus
                SendKeys "{Home}+{End}"
                If loginnum1 = 3 Then
                    MsgBox "你已经尝试了太多次,无法登陆,请找管理员联系!", , "关闭"
                    End
                End If
            End If
        End If
    Loop
End Sub

Private Sub Form_Activate()
If picname <> "" Then
    PicCaption.Picture = LoadPicture(picname)
    PicBorder.Picture = LoadPicture(picbname)
    Skin Me, m_cN
End If
txtPassword.Text = ""
txtUserName.Text = ""
txtUserName.SetFocus
End Sub

Private Sub Form_Load()

Data1.DatabaseName = App.Path & "\data\kaoti.mdb"
Loginnum = 0
Set m_cN = New cNeoCaption
Skin Me, m_cN
End Sub
Private Sub Form_Unload(Cancel As Integer)
End
End Sub

Private Sub Text3_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
    Text4.SetFocus
    SendKeys "{Home}+{End}"
End If
End Sub
Private Sub Text4_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
    Command3_Click
End If
End Sub

Private Sub txtPassword_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 And cmdOK.Visible = True Then
    cmdOK_Click
Else
    If KeyAscii = 13 Then
        Text3.SetFocus
        SendKeys "{Home}+{End}"
    End If
End If
End Sub

Private Sub txtUserName_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
    txtPassword.SetFocus
    SendKeys "{Home}+{End}"
End If
End Sub
Private Sub huifu()
cmdOK.Visible = True
cmdCancel.Visible = True
Command1.Visible = True
Command2.Visible = True
lblLabels(2).Visible = False
Text3.Visible = False
lblLabels(3).top = 957
Text4.top = 921
Command3.top = 1205
Command4.top = 1205
Command5.top = 1205
Me.Height = 2430
txtUserName.Text = ""
txtPassword.Text = ""
Text3.Text = ""
Text4.Text = ""
txtUserName.SetFocus
End Sub

⌨️ 快捷键说明

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