VB code snippet summary

foreword

  VB has been over for a period of time, and the understanding of VB code has become more in-depth in the middle. This change especially occurs in the computer room. The students did not understand the code very well. After arriving in the computer room, these codes are almost understood. I have also summarized a lot of code before. During this time, I have been helping others to debug errors, and I have discovered other knowledge to be understood. Briefly summarize!

Knowledge

  1. The drop-down box defaults to the first

Combo1.listindex=0

  2. Use of Int

a = Int(txtConsumeTime/mrc!unittime)
    If a = txtConsumeTime/mrc!unittime Then
       txtConsume = a
    Else
       txtConsume = a + 1
    End If

  This code is the code in the computer room. The premise a is to divide the total consumption time by the incremental unit. If a is equal to the total consumption time divided by the incremental unit, then the total consumption time is a, otherwise it is a+1. Because if a is a positive number, Int is rounded down to a, and spending 40 minutes in an Internet cafe is calculated on an hourly basis. So need to use Int.

  3. Display the number of fields in the table

labCount.Caption=mrconline.RecordCount

method

  1. Comment: The function of the code below - name - date

  Because the code of a big software will definitely not be typed by one person in the future, so in order to become a good project member in a good project team, it is necessary to standardize the code and clearly add comments!

  2. Modules

  First of all, you must understand the module, and then put it into the module for the common and frequently used code to prevent code redundancy.

  3. Code

  The code should be clear, concise and logical. It is not that the less the better, but that it should be understood by others.

Summarize

  This blog is a bit late, and there are some unexpected situations in the middle, but the methods in it should be paid attention to no matter which language we are learning, and now I summarize it and save it for experience!

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325661136&siteId=291194637