Registration form of computer room charging system

Preface

The charge system of the computer room has entered the registration window. I feel that the computer room is the same as many places of the students, but because the computer room is completed by myself, and the help from the outside is less, I have to sort out the logic by myself and design the code by myself (most of them are to find on the students and blogs, and then I will knock after understanding). At the beginning, I didn't have any idea. I didn't know where to start when I saw the finished product , after reading elder martial brother's blog, you can make logic.

primary coverage

1, Logic diagram


2, Code analysis
1. How to judge whether the text box is a number

If Not IsNumeric(Trim(txtCash.Text)) Then
  MsgBox "Wrong format!", vbOKOnly + vbExclamation, "reminder"
            txtCash.SetFocus
            txtCash.Text = ""
            Exit Sub
        End If

2. How to connect tables - query

 'Connection table, query card number—— cardno Equal to text box txtCardNo Part of the data entered in.
    txtSQL = "select * from student_Info where cardno= '" & Trim(txtCardNo.Text) & "'"
    Set mrc = ExecuteSQL(txtSQL, MsgText)

3. How to query whether the data exists in the database.

'Ergodic table
    If mrc.EOF = False Then
        MsgBox "The card number already exists, please re-enter!", vbOKOnly + vbExclamation, "reminder"
        txtCardNo.SetFocus
        txtCardNo.Text = ""
        Exit Sub
    End If

4. How to input data into the database. (update table)

mrc.AddNew
    mrc.Fields(0) = Trim(txtCardNo.Text)
    mrc.Fields(1) = Trim(txtSID.Text)
    mrc.Fields(2) = Trim(txtName.Text)
    mrc.Fields(3) = Trim(txtSex.Text)
    mrc.Fields(4) = Trim(txtDept.Text)
    mrc.Fields(5) = Trim(txtGrade.Text)
    mrc.Fields(6) = Trim(txtClass.Text)
    mrc.Fields(7) = Trim(txtCash.Text)
    mrc.Fields(8) = Trim(txtExplain.Text)
    mrc.Fields(9) = UserName
    mrc.Fields(10) = Trim(txtState.Text)
    mrc.Fields(11) = "Unclosed"
    mrc.Fields(12) = Date
    mrc.Fields(13) = Time
    mrc.Fields(14) = Trim(cmbType.Text)
    mrc.Update

3, Mistakes and problems encountered
1. The format of wildcard

 '" & Trim(txtCardNo.Text) & "'

In this part, the single quotation mark is used to input the information in SQL, and the double quotation mark is used to judge that what is inside is a string. In short, double quotation marks are for VB and single quotation marks are for SQL statements. What are the wildcards in it? I don't know yet.

Summary

Most of the codes of the registration form are the codes of the reference student management system, many of which can't be written by dictation, and their mastery of the code is still too poor. They should often knock on the code to strengthen the code learning. In addition, the logic is not clear. After reading many people's blogs, they understand that they need to improve their ability to solve problems independently next time.

Keywords: SQL Database less

Added by Stevis2002 on Sun, 03 May 2020 03:38:23 +0300