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

📄 register.frm

📁 Visual Basic开发实用编程200例 数据库编程实例
💻 FRM
字号:
VERSION 5.00
Object = "{86CF1D34-0C5F-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCT2.OCX"
Begin VB.Form Register 
   Caption         =   "注册"
   ClientHeight    =   5400
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   5685
   Icon            =   "Register.frx":0000
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MDIChild        =   -1  'True
   ScaleHeight     =   5400
   ScaleWidth      =   5685
   Begin VB.Frame FrameReg 
      Height          =   4815
      Left            =   360
      TabIndex        =   1
      Top             =   360
      Width           =   4815
      Begin VB.CommandButton cmdReg 
         Caption         =   "注册"
         Default         =   -1  'True
         Height          =   495
         Left            =   240
         TabIndex        =   15
         Top             =   4080
         Width           =   4215
      End
      Begin VB.TextBox txtUnit 
         Height          =   855
         Left            =   1200
         MaxLength       =   50
         MultiLine       =   -1  'True
         ScrollBars      =   2  'Vertical
         TabIndex        =   14
         Top             =   2880
         Width           =   3015
      End
      Begin MSComCtl2.UpDown udAge 
         Height          =   270
         Left            =   1666
         TabIndex        =   12
         Top             =   2272
         Width           =   270
         _ExtentX        =   423
         _ExtentY        =   476
         _Version        =   393216
         Value           =   21
         AutoBuddy       =   -1  'True
         BuddyControl    =   "txtAge"
         BuddyDispid     =   196612
         OrigLeft        =   1680
         OrigTop         =   2280
         OrigRight       =   1950
         OrigBottom      =   2535
         Max             =   150
         Min             =   1
         SyncBuddy       =   -1  'True
         BuddyProperty   =   65547
         Enabled         =   -1  'True
      End
      Begin VB.TextBox txtAge 
         Height          =   270
         Left            =   1200
         MaxLength       =   3
         TabIndex        =   11
         Top             =   2272
         Width           =   465
      End
      Begin VB.TextBox txtRealname 
         Height          =   270
         Left            =   1200
         MaxLength       =   10
         TabIndex        =   9
         Top             =   1800
         Width           =   3015
      End
      Begin VB.TextBox txtPwAgain 
         Height          =   270
         IMEMode         =   3  'DISABLE
         Left            =   1200
         MaxLength       =   20
         PasswordChar    =   "*"
         TabIndex        =   7
         Top             =   1320
         Width           =   3015
      End
      Begin VB.TextBox txtPassword 
         Height          =   270
         IMEMode         =   3  'DISABLE
         Left            =   1200
         MaxLength       =   20
         PasswordChar    =   "*"
         TabIndex        =   5
         Top             =   840
         Width           =   3015
      End
      Begin VB.TextBox txtUserName 
         Height          =   270
         Left            =   1200
         MaxLength       =   20
         TabIndex        =   3
         Top             =   360
         Width           =   3015
      End
      Begin VB.Label Label8 
         Caption         =   "*"
         Height          =   255
         Index           =   2
         Left            =   4320
         TabIndex        =   18
         Top             =   1320
         Width           =   255
      End
      Begin VB.Label Label8 
         Caption         =   "*"
         Height          =   255
         Index           =   1
         Left            =   4320
         TabIndex        =   17
         Top             =   840
         Width           =   255
      End
      Begin VB.Label Label8 
         Caption         =   "*"
         Height          =   255
         Index           =   0
         Left            =   4320
         TabIndex        =   16
         Top             =   360
         Width           =   255
      End
      Begin VB.Label Label7 
         Caption         =   "班级:"
         Height          =   255
         Left            =   240
         TabIndex        =   13
         Top             =   2880
         Width           =   735
      End
      Begin VB.Label Label6 
         Caption         =   "年龄:"
         Height          =   255
         Left            =   240
         TabIndex        =   10
         Top             =   2280
         Width           =   615
      End
      Begin VB.Label Label5 
         Caption         =   "真实姓名:"
         Height          =   255
         Left            =   240
         TabIndex        =   8
         Top             =   1815
         Width           =   1095
      End
      Begin VB.Label Label4 
         Caption         =   "确认密码:"
         Height          =   255
         Left            =   240
         TabIndex        =   6
         Top             =   1335
         Width           =   975
      End
      Begin VB.Label Label3 
         Caption         =   "密码:"
         Height          =   255
         Left            =   240
         TabIndex        =   4
         Top             =   855
         Width           =   735
      End
      Begin VB.Label Label2 
         Caption         =   "用户名:"
         Height          =   255
         Left            =   240
         TabIndex        =   2
         Top             =   375
         Width           =   975
      End
   End
   Begin VB.Label Label1 
      Caption         =   "欢迎注册成为新用户!(打*号为必添项)"
      ForeColor       =   &H00FF0000&
      Height          =   255
      Left            =   360
      TabIndex        =   0
      Top             =   120
      Width           =   4935
   End
End
Attribute VB_Name = "Register"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub cmdReg_Click()
    'Dim cmd As Command
    
    Usertype = General
    State = 1
 
    Set cmd = New Command
    DataE.Connections("conLibrary").Open
    cmd.ActiveConnection = DataE.Connections("conLibrary")
    cmd.CommandText = "insert into UserTable(UserName,RealName,Unit,pwd,RegisterTime,age,state,usertype) values('" & txtUserName.Text & "','" & txtRealname.Text & "','" & txtUnit.Text & "','" & txtPassword.Text & "','" & Now & "','" & udAge.Value & "','" & State & "','" & Usertype & "')"
    cmd.CommandText = "select * from usertable where username='" & txtUserName & "'"

    '子段不要使用关键字“PassWord”
    '验证重要信息已经填写
    If txtUserName.Text = "" Then
        MsgBox "请填写用户名!", vbOKOnly + vbInformation, "注意"
        txtUserName.SetFocus
        Exit Sub
    ElseIf txtPassword.Text = "" Then
        MsgBox "请填写密码!", vbOKOnly + vbInformation, "注意"
        txtPassword.SetFocus
        Exit Sub
    ElseIf txtPwAgain.Text = "" Then
        MsgBox "请填写确认密码!", vbOKOnly + vbInformation, "注意"
        txtPwAgain.SetFocus
        Exit Sub
    
    End If
    
    If txtPassword.Text <> txtPwAgain.Text Then
        MsgBox "两次密码不相同,请重新填写!", vbOKOnly + vbInformation, "注意"
        txtPassword.Text = ""
        txtPwAgain.Text = ""
        txtPassword.SetFocus
        Exit Sub
    End If
    
    On Error GoTo exit1
    If Not IsExistUser(txtUserName, "") Then
    '添加用户
        DataE.cmdAdd txtUserName, txtPassword, txtRealname, txtUnit, Now, udAge, Usertype, State
        
        MsgBox "注册成功!", vbOKOnly + vbInformation, "注意"
        Unload Me
        frmSearch.Show
    Else
        MsgBox "用户已经存在!请重新注册一个新的用户名", vbOKOnly + vbInformation, "注意"
        txtUserName.Text = ""
        txtPassword.Text = ""
        txtPwAgain.Text = ""
        txtUserName.SetFocus
    End If
    Exit Sub
   
    
exit1:
    MsgBox "数据未成功写入数据库!", vbOKOnly + vbInformation, "错误"
    Exit Sub
End Sub

Private Sub Form_Load()
    txtAge.Text = CStr(udAge.Value)
    Register.Height = 5800
    Register.Width = 5800
    Register.Top = 2000
    Register.Left = 4000
    
    mdiFrm.mnuReg.Enabled = False
End Sub

Private Sub Form_Unload(Cancel As Integer)
    mdiFrm.mnuReg.Enabled = True
End Sub

Private Sub Label5_Click()

End Sub

⌨️ 快捷键说明

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