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

📄 form2.frm

📁 VB和ACCESS作的物品管理软件 比较容易分析
💻 FRM
字号:
VERSION 5.00
Begin VB.Form Form2 
   Caption         =   "添加用户系统"
   ClientHeight    =   3360
   ClientLeft      =   60
   ClientTop       =   450
   ClientWidth     =   5370
   LinkTopic       =   "Form2"
   ScaleHeight     =   3360
   ScaleWidth      =   5370
   StartUpPosition =   3  'Windows Default
   Begin VB.CommandButton Command2 
      Caption         =   "取消"
      Height          =   375
      Left            =   4080
      TabIndex        =   13
      Top             =   2760
      Width           =   735
   End
   Begin VB.CommandButton Command1 
      Caption         =   "提交"
      Height          =   375
      Left            =   2760
      TabIndex        =   12
      Top             =   2760
      Width           =   735
   End
   Begin VB.Frame Frame2 
      Caption         =   "用户权限"
      Height          =   1935
      Left            =   3720
      TabIndex        =   7
      Top             =   480
      Width           =   1455
      Begin VB.OptionButton Option2 
         Caption         =   "Option2"
         Height          =   375
         Left            =   240
         TabIndex        =   9
         Top             =   1200
         Width           =   255
      End
      Begin VB.OptionButton Option1 
         Caption         =   "Option1"
         Height          =   255
         Left            =   240
         TabIndex        =   8
         Top             =   600
         Width           =   255
      End
      Begin VB.Label Label5 
         Caption         =   "只读用户"
         Height          =   255
         Left            =   600
         TabIndex        =   11
         Top             =   1200
         Width           =   735
      End
      Begin VB.Label Label4 
         Caption         =   "管理员"
         Height          =   255
         Left            =   600
         TabIndex        =   10
         Top             =   600
         Width           =   615
      End
   End
   Begin VB.Frame Frame1 
      Caption         =   "添加用户"
      Height          =   1935
      Left            =   480
      TabIndex        =   0
      Top             =   480
      Width           =   3015
      Begin VB.TextBox Text3 
         Height          =   375
         IMEMode         =   3  'DISABLE
         Left            =   1320
         PasswordChar    =   "*"
         TabIndex        =   6
         Top             =   1440
         Width           =   1095
      End
      Begin VB.TextBox Text2 
         Height          =   375
         IMEMode         =   3  'DISABLE
         Left            =   1320
         PasswordChar    =   "*"
         TabIndex        =   4
         Top             =   840
         Width           =   1095
      End
      Begin VB.TextBox Text1 
         Height          =   405
         Left            =   1320
         TabIndex        =   2
         Top             =   240
         Width           =   1095
      End
      Begin VB.Label Label3 
         Caption         =   "确认密码"
         Height          =   255
         Left            =   360
         TabIndex        =   5
         Top             =   1560
         Width           =   735
      End
      Begin VB.Label Label2 
         Caption         =   "密码"
         Height          =   255
         Left            =   360
         TabIndex        =   3
         Top             =   960
         Width           =   615
      End
      Begin VB.Label Label1 
         Caption         =   "用户名"
         Height          =   255
         Left            =   360
         TabIndex        =   1
         Top             =   360
         Width           =   615
      End
   End
End
Attribute VB_Name = "Form2"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Command1_Click()
   Dim cnn1 As ADODB.Connection
   Dim userpword As ADODB.Recordset
   Dim strcnn As String
   
    If Trim(Text1.Text) = "" Then
        MsgBox "请输入用户名称!", vbOKOnly + vbExclamation, "警告"
        Text1.SetFocus
        Exit Sub
    Else
        strcnn = "Provider=MSDASQL.1;Persist Security Info=False;Data Source=db1"
        Set cnn1 = New ADODB.Connection
        cnn1.Open strcnn
        Set userpword = New ADODB.Recordset
        userpword.LockType = adLockOptimistic
        userpword.Open "select * from use", cnn1, , , adCmdText
        While (userpword.EOF = False)
            If Trim(userpword.Fields(0)) = Trim(Text1.Text) Then
                MsgBox "用户已经存在,请重新输入用户名!", vbOKOnly + vbExclamation, "警告"
                Text1.SetFocus
                Text1.Text = ""
                Text2.Text = ""
                Text3.Text = ""
                Exit Sub
            Else
                userpword.MoveNext
            End If
        Wend
    End If
    
    If Trim(Text2.Text) <> Trim(Text3.Text) Then
        MsgBox "两次输入密码不一样,请确认!", vbOKOnly + vbExclamation, "警告"
        Text2.SetFocus
        Text2.Text = ""
        Text3.Text = ""
        Exit Sub
        
    Else
        If Text2.Text = "" Then
            MsgBox "密码不能为空!", vbOKOnly + vbExclamation, "警告"
            Text2.SetFocus
            Text2.Text = ""
            Text3.Text = ""
        Else
            userpword.AddNew
            userpword.Fields(0) = Trim(Text1.Text)
            userpword.Fields(1) = Trim(Text2.Text)
            If Option1.Value Then
                userpword.Fields(2) = "y"
            Else
                userpword.Fields(3) = "y"
            End If
            userpword.Update
            userpword.Close
            MsgBox "添加用户成功!", vbOKOnly + vbExclamation, "添加用户"
        End If
    End If
End Sub

Private Sub Command2_Click()
    Unload Me
End Sub

⌨️ 快捷键说明

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