Add user interface
Today , I made an interface for adding users, which is also a very simple applet. At present, this program has not been optimized, and the form of expression has been changed. I used to manually add user names. This time, I made a small program. Improve. Set the user name ID to increase automatically in the database, and then automatically read the user name ID in the database in the add user interface , which is equivalent to applying for a QQ number, the system will automatically give a user name ID . The database settings are relatively simple to illustrate by a screenshot:
Just set the logo seed and logo increment in the logo specification.
After setting up the database, the next step is to write the code to implement this function. The code used in it is the code that has been learned before, and now it is taken out and used again. The specific code is as follows:
Option Explicit Private Sub Command1_Click() Dim mrc As ADODB.Recordset Dim msgtext As String Dim txtSQL As String Dim admin As String 'Check if the content is empty 'The user name is given after the database number, and the user name column directly reads the new user name number (2017.12.22) has been completed If (TxtUserName.Text = "") Then MsgBox "Name cannot be empty!", vbOKOnly + vbExclamation, "Warning" Exit Sub End If If (TxtPWD.Text = "") Then MsgBox "Password cannot be empty!", vbOKOnly + vbExclamation, "Warning" Exit Sub End If If (TxtRPWD.Text = "") Then MsgBox "Confirm password cannot be empty!", vbOKOnly + vbExclamation, "Warning" Exit Sub End If If (ComHead.Text = "") Then MsgBox "Please select user level!", vbOKOnly + vbExclamation, "Warning" Exit Sub End If txtSQL = "select*from user_info" Set mrc = ExecuteSQL(txtSQL, msgtext) 'Read the user name number (2) without exiting in the add user interface mrc.MoveLast Label6.Caption = mrc.Fields(0) + 2 'Judging that the two input passwords are not the same If Trim(TxtPWD.Text) <> Trim(TxtRPWD.Text) Then MsgBox "The passwords entered twice are different, please confirm and enter again!", vbOKOnly + vbExclamation, "Warning" TxtRPWD = "" Exit Sub Else 'Judging that the password input box cannot be empty If TxtPWD.Text = "" Then MsgBox "Password cannot be empty!", vbOKOnly + vbExclamation, "Warning" Exit Sub Else 'Add new record mrc.AddNew 'mrc.Fields(0) = Trim(TxtuserID.Text) mrc.Fields(3) = Trim(TxtUserName.Text) mrc.Fields(1) = Trim(TxtPWD.Text) mrc.Fields(2) = Trim(ComHead.Text) mrc.Fields(4) = Trim("admin") 'update database mrc.Update MsgBox "User added successfully!", vbOKOnly + vbExclamation, "Warning" 'TxtuserID.Text = "" TxtUserName.Text = "" TxtPWD.Text = "" TxtRPWD.Text = "" ComHead.Text = "" Exit Sub End If End If End Sub Private Sub Command3_Click() TxtuserID.Text = "" TxtUserName.Text = "" TxtPWD.Text = "" TxtRPWD.Text = "" ComHead.Text = "" End Sub Private Sub Form_Load() Dim mrc As ADODB.Recordset Dim msgtext As String Dim txtSQL As String txtSQL = "select*from user_info" Set mrc = ExecuteSQL(txtSQL, msgtext) 'Read the user name number (1) after entering the add interface mrc.MoveLast Label6.Caption = mrc.Fields(0) + 1 ComHead.AddItem "Administrator" ComHead.AddItem "Operator" ComHead.AddItem "General User" End Sub
At the same time, the design diagram of the interface control is attached.