VB6 coding Specification

Source: Internet
Author: User

VB6 coding specifications for the project team

----

VB6 coding Specification

This code specification is formulated to facilitate maintenance and development, as well as to reduce detours for subsequent maintenance personnel.
This specification is an entertainment edition specification.

Before reading the coding rules, consider the following questions. If you do not know the answer, search online.
To deepen memory
1. Dim I, j, k as integer and dim I as interger, J as interger, K as interger have
What is the difference?
2. What does option explicit mean?
3. What is the difference between sub and function?
4. What are the differences between dim, private, and public variables in a module (modula?
5. Under what circumstances will the property be used?

VB6 specifications officially launched:
1. Dim I, J, K, L as integer
K said: I have two hobbies.
One is to stand in the same line as other variables.
Second, put on the variant coat and asked everyone to "guess who I am"
PS: each row only declares one variable
2. Mid $ and mid. This is a pair of twins, and the returned values are of different types. Although some people say that mid $ is faster than mid
The actual speed is almost the same. In addition, when the VB code is upgraded to VB. NET
Save for a period of time, and versions without $ are easier to compare code. Therefore, use the mid version without $.
3. Dim F as form
F = new form1
F. dowork
F = new form2
F. dootherwork
F said: F1 and F2 are silly and unclear. Actually, I am like F4.
PS: Use clear types whenever possible when defining variables
4. Uncle option explicit said: Check accounts and accounts, and all accounts without accounts go to Changping to dig sand; But Microsoft
I am not allowed to take the initiative to attack. You asked me to check my account.
PS: at the beginning of each file, write "option explicit"
Alternatively, you can check the parameters before tools> Option> editor> require variable declaration.
5. Function Foo ()
If... then
Function = CINT (1)
Else if...
Function = "I'm a string"
Else if...
...
End if
End Function
Foo said: Jolin's "watch my 72 changes" is an inspiration from me. As for whether you believe it or not, I am anti-fraud.
It is a message. If you don't believe it, I'll show it to you.
PS: a function with a returned value. You must specify the type of the returned value.
6. Sub said: Hi, I am one of the changes in function 72. My biggest characteristic is that I don't vomit grape skins when I eat grapes.
PS: a function with no return value. It is defined using sub.
7. the SQL statement is long and needs to be written separately in multiple rows. A space is added at the beginning and end of each line to reduce the output
Error, such as "select * from"
8. SQL = "select * from table where name =" & Username
The database says: the cache has been refreshed and never used. To be quick, go to the VIP channel.
The hacker said: even code that cannot be prevented by SQL injection is an insult to my ability.
PS: the variables in SQL statements should be parameterized as much as possible, instead of directly spelling strings-None
From the perspective of performance and security
9. Do not reinvent the wheel. Before you need to implement a function, find the existing Code
10. Write frequently used functions into modules to improve the versatility and maintainability of the program

 

Tools:
To do good deeds, the husband must first sharpen his weapon. Good tools will greatly improve work efficiency, saving time for Weibo Mining
8 GB
1. Install VB6 SP6
2. Install codesmart 2009.

 

VB6 will automatically change the variable case. Therefore, use the following procedure:
1. Backup code
2. write code and modify bugs
3. Use the review function of codesmart to check the code
4. Use Beyond compare to compare the code and change the variable VB6 that automatically changes the case sensitivity back.
5. Submit code to code management servers such as CVS, SVN, and CC.

 

References:
VB6 coding Specification
Http://www.360doc.com/content/06/0822/10/6002_187392.shtml
Http://www.bianceng.cn/VBjc/jyjq/jy1.htm
VB6 SP6
Http://www.microsoft.com/downloads/zh-cn/details.aspx? Familyid = 9ef9bf70-
Dfe1-42a1-a4c8-39718c7e381d & displaylang = ZH-CN
VB6 SP6 cumulative update
Http://support.microsoft.com/kb/957924/en-us
Codesmart Functions
Http://www.axtools.com/products-codesmart-vb6.php
Use the variable binding method (Oracle SQL sharing mechanism)
Http://blog.csdn.net/yspoplar/article/details/5904644

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.