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

📄 frmadduser.frm

📁 一个自己做的电力管理系统,主要用于电力电业行业的管理
💻 FRM
字号:
VERSION 5.00
Begin VB.Form frmAdduser 
   BackColor       =   &H00FFC0FF&
   BorderStyle     =   3  'Fixed Dialog
   Caption         =   "添加用户"
   ClientHeight    =   5115
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   6150
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   5115
   ScaleWidth      =   6150
   ShowInTaskbar   =   0   'False
   StartUpPosition =   3  'Windows Default
   Begin VB.PictureBox Picture1 
      BackColor       =   &H00FFC0FF&
      BorderStyle     =   0  'None
      Height          =   495
      Left            =   120
      Picture         =   "frmAdduser.frx":0000
      ScaleHeight     =   495
      ScaleWidth      =   5415
      TabIndex        =   9
      Top             =   960
      Width           =   5415
   End
   Begin VB.CommandButton OKButton 
      Caption         =   "确定"
      Default         =   -1  'True
      Height          =   495
      Left            =   1560
      TabIndex        =   4
      Top             =   4320
      Width           =   1215
   End
   Begin VB.CommandButton CancelButton 
      Cancel          =   -1  'True
      Caption         =   "取消"
      Height          =   495
      Left            =   3240
      TabIndex        =   3
      Top             =   4320
      Width           =   1215
   End
   Begin VB.TextBox txtUser 
      BackColor       =   &H00C0FFFF&
      Height          =   480
      Left            =   1440
      TabIndex        =   2
      Top             =   2160
      Width           =   3135
   End
   Begin VB.TextBox txtPassword 
      BackColor       =   &H00C0FFFF&
      Height          =   480
      IMEMode         =   3  'DISABLE
      Left            =   1440
      PasswordChar    =   "*"
      TabIndex        =   1
      Top             =   2880
      Width           =   3135
   End
   Begin VB.TextBox txtCom 
      BackColor       =   &H00C0FFFF&
      Height          =   480
      IMEMode         =   3  'DISABLE
      Left            =   1440
      PasswordChar    =   "*"
      TabIndex        =   0
      Top             =   3480
      Width           =   3135
   End
   Begin VB.Label Label4 
      BackColor       =   &H00FFC0FF&
      Caption         =   "欢迎你成为新的用户!"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   26.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H000000C0&
      Height          =   615
      Left            =   240
      TabIndex        =   8
      Top             =   240
      Width           =   5295
   End
   Begin VB.Label Label1 
      AutoSize        =   -1  'True
      BackColor       =   &H00FFC0FF&
      Caption         =   "用户名:"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   12
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   300
      Left            =   240
      TabIndex        =   7
      Top             =   2280
      Width           =   1020
   End
   Begin VB.Label Label2 
      AutoSize        =   -1  'True
      BackColor       =   &H00FFC0FF&
      Caption         =   "密码:"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   12
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   300
      Left            =   360
      TabIndex        =   6
      Top             =   3000
      Width           =   765
   End
   Begin VB.Label Label3 
      AutoSize        =   -1  'True
      BackColor       =   &H00FFC0FF&
      Caption         =   "再次输入密码:"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   9.75
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   240
      Left            =   120
      TabIndex        =   5
      Top             =   3600
      Width           =   1365
   End
End
Attribute VB_Name = "frmAdduser"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
          

Private Sub CancelButton_Click()  '退出本窗体
    Me.Hide
End Sub


Private Sub Form_Paint()         '清空用户名,密码
    Me.txtUser.Text = ""
    Me.txtPassword.Text = ""
    Me.txtCom.Text = ""
    Me.txtUser.SetFocus
    MakeCenter Me                '窗体位于屏幕中间
End Sub

Private Sub OKButton_Click()     '将密码写入数据库
On Error GoTo errh
       Set rs = New ADODB.Recordset
         If Me.txtUser.Text <> "" Then
            If Me.txtPassword.Text <> "" Then
                If Me.txtCom.Text = Me.txtPassword.Text Then
                    Set rs = New ADODB.Recordset
                    MakeConnection
                    rs.LockType = adLockOptimistic
                    rs.CursorType = adOpenKeyset
                    rs.Open "用户", CN, , , adCmdTable
                    rs.AddNew
                    rs.Fields("Password").Value = Me.txtPassword.Text
                    rs.Fields("UserName").Value = Me.txtUser.Text
                    rs.Update
                    delConnection      '断开连接数据库
                    Me.Hide
                    MsgBox "添加成功"
                Else
                    MsgBox "密码错误,请重新输入!"
                End If
            Else
               MsgBox "密码不能为空,请输入密码!"
            End If
        Else
            MsgBox "用户名不能为空"
        End If
      Exit Sub
errh:                                   '出错处理
    MsgBox Err.Description
End Sub

⌨️ 快捷键说明

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