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

📄 frmadduser.frm

📁 通过对空间数据的分析
💻 FRM
字号:
VERSION 5.00
Begin VB.Form frmAddUser 
   Caption         =   "注册新用户"
   ClientHeight    =   3660
   ClientLeft      =   60
   ClientTop       =   435
   ClientWidth     =   4230
   LinkTopic       =   "Form1"
   ScaleHeight     =   3660
   ScaleWidth      =   4230
   StartUpPosition =   3  '窗口缺省
   Begin VB.CommandButton Command2 
      Caption         =   "取消"
      Height          =   495
      Left            =   2520
      TabIndex        =   8
      Top             =   3000
      Width           =   1095
   End
   Begin VB.CommandButton Command1 
      Caption         =   "注册"
      Height          =   495
      Left            =   480
      TabIndex        =   7
      Top             =   3000
      Width           =   1095
   End
   Begin VB.Frame Frame1 
      Caption         =   "新用户"
      Height          =   2535
      Left            =   0
      TabIndex        =   0
      Top             =   240
      Width           =   3975
      Begin VB.TextBox Text3 
         Height          =   375
         IMEMode         =   3  'DISABLE
         Left            =   1560
         PasswordChar    =   "*"
         TabIndex        =   6
         Top             =   1800
         Width           =   1455
      End
      Begin VB.TextBox Text2 
         Height          =   375
         IMEMode         =   3  'DISABLE
         Left            =   1560
         PasswordChar    =   "*"
         TabIndex        =   5
         Top             =   960
         Width           =   1455
      End
      Begin VB.TextBox Text1 
         Height          =   375
         Left            =   1560
         TabIndex        =   3
         Top             =   240
         Width           =   1455
      End
      Begin VB.Label Label3 
         AutoSize        =   -1  'True
         Caption         =   "确认密码"
         Height          =   180
         Left            =   240
         TabIndex        =   4
         Top             =   1680
         Width           =   720
      End
      Begin VB.Label Label2 
         AutoSize        =   -1  'True
         Caption         =   "输入密码"
         Height          =   180
         Left            =   240
         TabIndex        =   2
         Top             =   960
         Width           =   720
      End
      Begin VB.Label Label1 
         AutoSize        =   -1  'True
         Caption         =   "用户名"
         Height          =   180
         Left            =   240
         TabIndex        =   1
         Top             =   360
         Width           =   540
      End
   End
End
Attribute VB_Name = "frmAddUser"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Command1_Click()
 '先检查用户是否输入了必要的各项值
   If Text1.Text = "" Then
      MsgBox "请输入用户名!", vbOKOnly + vbInformation, "注意"
      Text1.SetFocus
      Exit Sub
   ElseIf Text2.Text = "" Then
      MsgBox "请输入密码!", vbOKOnly + vbInformation, "注意"
      Text2.SetFocus
      Exit Sub
   ElseIf Text3.Text = "" Then
      MsgBox "请再次输入密码!", vbOKOnly + vbInformation, "注意"
      Text3.SetFocus
      Exit Sub
  End If
   '判断两次输入的密码是否相同
   If Text2.Text <> Text3.Text Then
      MsgBox "两次输入的密码不同,请重新输入密码!", vbOKOnly + vbInformation, "注意"
      Text2.Text = ""
      Text3.Text = ""
      Text2.SetFocus
      Exit Sub
   End If
   Dim rs_check As New ADODB.Recordset
   Dim rs_add As New ADODB.Recordset
   Dim strsql As String
   '构造查询该用户名语句
   strsql = "select * from sjk where 用户名 = '" & Text1.Text & "'"
   rs_check.open strsql, conn, adLockPessimistic
   '判断是否已存在此用户名
   If rs_check.EOF = False Then
      MsgBox "此用户名已存在,请选择其他用户名!", vbOKOnly + vbInformation, "注意"
      Text1.Text = ""
      Text1.SetFocus
      rs_check.Close
      Exit Sub
   End If
   '添加新用户信息入用户表
   Dim sqladd As String
   sqladd = "select * from sjk"
   rs_add.open sqladd, conn, adOpenKeyset, adLockPessimistic
   rs_add.AddNew
   rs_add.Fields(0) = Text1.Text
   rs_add.Fields(1) = Text2.Text
   rs_add.Update
   MsgBox "注册成功!祝贺你!", vbOKOnly + vbInformation, "注意"
   rs_check.Close
   rs_add.Close
   Unload Me
End Sub

Private Sub Command2_Click()
   Text1.Text = ""
   Text2.Text = ""
   Text3.Text = ""
End Sub

Private Sub Form_Load()
 Dim X0 As Long
   Dim Y0 As Long
   '让窗体居中
   X0 = Screen.Width
   Y0 = Screen.Height
   X0 = (X0 - Me.Width) / 2
   Y0 = (Y0 - Me.Height) / 2
   Me.Move X0, Y0
End Sub

⌨️ 快捷键说明

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