form11.frm

来自「本人课程设计做的一个简单的教务辅助管理系统,实现了数据库的一般操作,适合初学者学」· FRM 代码 · 共 147 行

FRM
147
字号
VERSION 5.00
Begin VB.Form 添加用户 
   Caption         =   "Form9"
   ClientHeight    =   3495
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   4410
   LinkTopic       =   "Form9"
   ScaleHeight     =   3495
   ScaleWidth      =   4410
   StartUpPosition =   3  '窗口缺省
   Begin VB.CommandButton Command2 
      Caption         =   "退出"
      Height          =   495
      Left            =   2280
      TabIndex        =   8
      Top             =   2760
      Width           =   1215
   End
   Begin VB.CommandButton Command1 
      Caption         =   "确认"
      Height          =   495
      Left            =   720
      TabIndex        =   7
      Top             =   2760
      Width           =   1335
   End
   Begin VB.TextBox Text3 
      Height          =   495
      IMEMode         =   3  'DISABLE
      Left            =   1920
      PasswordChar    =   "*"
      TabIndex        =   6
      Top             =   2040
      Width           =   1335
   End
   Begin VB.TextBox Text2 
      Height          =   495
      IMEMode         =   3  'DISABLE
      Left            =   1920
      PasswordChar    =   "*"
      TabIndex        =   4
      Top             =   1320
      Width           =   1335
   End
   Begin VB.TextBox Text1 
      Height          =   495
      Left            =   1920
      TabIndex        =   2
      Top             =   720
      Width           =   1335
   End
   Begin VB.Label Label4 
      Caption         =   "确认密码"
      Height          =   255
      Left            =   960
      TabIndex        =   5
      Top             =   2160
      Width           =   855
   End
   Begin VB.Label Label3 
      Caption         =   "密码"
      Height          =   255
      Left            =   1080
      TabIndex        =   3
      Top             =   1440
      Width           =   495
   End
   Begin VB.Label Label2 
      Caption         =   "用户名"
      Height          =   255
      Left            =   1080
      TabIndex        =   1
      Top             =   720
      Width           =   735
   End
   Begin VB.Label Label1 
      Caption         =   "        添加用户"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   15
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   360
      TabIndex        =   0
      Top             =   120
      Width           =   3375
   End
End
Attribute VB_Name = "添加用户"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Command1_Click()
Set con = New ADODB.Connection
Set rs = New ADODB.Recordset
Set qrs = New ADODB.Recordset
If Text1.Text = "" Then
        MsgBox "请输入用户名!", vbOKOnly + vbExclamation, "警告"
        Text1.SetFocus
        Exit Sub
    End If
    If Text2.Text = "" Then
        MsgBox "请输入密码!", vbOKOnly + vbExclamation, "警告"
        Text2.SetFocus
        Exit Sub
    End If
    If Text3.Text = "" Then
        MsgBox "请输入确认密码!", vbOKOnly + vbExclamation, "警告"
        Text3.SetFocus
        Exit Sub
    End If
    con.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\教务管理系统.mdb;Persist Security Info=False"
    rs.Open "SELECT * FROM 登录表 WHERE 用户='" & Trim(Text1.Text) & " '", con, adOpenStatic, adLockOptimistic
    
If rs.RecordCount > 0 Then

        MsgBox "用户名已存在!", vbOKOnly + vbExclamation, "警告"
   Else
   If Text2.Text = Text3.Text Then
   
   rs.AddNew
   rs.Fields(0) = Text1.Text
 rs.Fields(1) = Text2.Text

                     rs.Update
                  MsgBox "添加成功!"
                  Text1.Text = ""
                  Text2.Text = ""
                  Text3.Text = ""
   Else
   MsgBox "确认密码与密码不同!", vbOKOnly + vbExclamation, "警告"
   End If
    End If

End Sub

Private Sub Command2_Click()
Unload Me
End Sub

⌨️ 快捷键说明

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