In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-21 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly introduces "how to understand VBScript coding convention". In daily operation, I believe many people have doubts about how to understand VBScript coding convention. The editor consulted all kinds of data and sorted out simple and easy-to-use methods of operation. I hope it will be helpful for you to answer the doubt of "how to understand VBScript coding convention". Next, please follow the editor to study!
Coding conventions are some suggestions to help you write code in Microsoft Visual Basic Scripting Edition. The coding convention includes the following:
Naming conventions for objects, variables, and procedures
Annotation convention
Guidelines for text formatting and indentation
The main reason for using consistent coding conventions is to standardize the structure and coding style of scripts or script sets so that the code is easy to read and understand. Using good coding conventions can make the source code clear, readable, accurate, more intuitive and consistent with other language conventions.
Constant naming convention
Previous versions of VBScript did not allow the creation of user-defined constants. If you want to use constants, the constants are implemented as variables, and all letters are capitalized to distinguish them from other variables. Multiple words in constant names are separated by an underscore (_). For example:
USER_LIST_MAX NEW_LINE
This method of identifying constants is still possible, but there are other options for creating real constants with Const statements. This convention uses a mixed case format with "con" as the prefix for the constant name. For example:
ConYourOwnConstant variable naming convention
To improve readability and consistency, use the following variable naming convention in your VBScript code:
Subtype prefix sample BooleanblnblnFoundBytebytbytRasterDataDate (Time) dtmdtmStartDoubledbldblToleranceErrorerrerrOrderNumIntegerintintQuantityLonglnglngDistanceObjectobjobjCurrentSinglesngsngAverageStringstrstrFirstName variable scope
Variables should be defined in the smallest possible scope. The scope of the VBScript variable is as follows:
Scope declares a visibility process-level event, function, or subprocedure at a variable. Visible in the process of declaring variables. The HEAD part of a Script-level HTML page, outside of any process. Visible in all the processes of the script. Variable scope prefix
As the length of the script code increases, it is necessary to quickly distinguish the scope of variables. Adding a single-character prefix to the type prefix can do this without causing the variable name to be too long.
Scope prefix sample procedure-level no dblVelocityScript-level ssblnCalcInProgress descriptive variable name and procedure name
The body of a variable or procedure name should use a mixed case format and describe its purpose as fully as possible. In addition, the procedure name should start with a verb, such as InitNameArray or CloseDialog.
For frequently used or longer names, it is recommended that you use standard abbreviations to keep the name within the appropriate length. Variable names that are usually more than 32 characters can become difficult to read. When using abbreviations, make sure that they are consistent throughout the script. For example, switching between Cnt and Count at will in a script or script set can cause confusion.
Object naming convention
The following table lists the object naming conventions that may be used in VBScript (recommended):
Object type prefix example 3D panel pnlpnlGroup animation button anianiMailBox check box chkchkReadOnly combination box, drop-down list box cbocboEnglish command button cmdcmdExit public dialog box dlgdlgFileOpen frame frafraLanguage horizontal scroll bar hsbhsbVolume image lbllblHelpMessage straight line linlinVertical list box lstlstPolicyCodes knob spnspnPages text box txttxtLastName vertical scroll bar vsbvsbRate slider sldsldScale code annotation convention
The beginning of all procedures should have brief comments that describe their functions. These comments do not describe the details (how to implement the function) because the details sometimes change frequently. This avoids unnecessary annotation maintenance and incorrect comments. The details are described by the code itself and the necessary internal comments.
It should be explained when the use of the parameters passed to the process is not obvious, or when the process has requirements for the value range of the parameters. If the procedure changes the return value of functions and variables (especially through parameter references), the return value should also be described at the beginning of the procedure.
The comments at the beginning of the process should contain the following section title. For examples, see the "formatting Code" section below.
The function of the section title comment content purpose process (not the way to implement the function). Assume that its state affects the list of external variables, controls, or other elements of this process. A list of the effects of the effect process on each external variable, control, or other element. Enter an explanation of each parameter for which the purpose is not obvious. Each parameter should occupy a separate line and have its internal comments. Returns an explanation of the return value.
Keep the following points in mind:
Every important variable declaration should have an internal comment describing the purpose of the variable.
Variables, controls, and procedures should be named clearly, and internal comments are required only when explaining complex details.
An overview describing the script should be included at the beginning of the script, listing objects, procedures, algorithms, dialog boxes, and other system dependencies. Sometimes it is useful to have a false code that describes the algorithm.
Formatting code
You should reserve as much screen space as possible, but still allow logical structure and nesting to be reflected in code formats. Here are a few tips:
Standard nested blocks should be indented by 4 spaces.
An overview of the process comments should be indented by 1 space.
The top-level statement after an overview comment should be indented by 4 spaces, and each layer of nested blocks should be indented by 4 more spaces. For example:
'* *' Purpose: Locates the first occurrence of a specified user'in the UserList array.' Inputs: strUserList (): the list of users to be searched.' StrTargetUser: the name of the user to search for.' Returns: The index of the first occurrence of the strTargetUser'in the strUserList array. ' If the target user is not found, return-1.'***Function intFindUser (strUserList (), strTargetUser) Dim I 'Loop counter. Dim blnFound 'Target found flag intFindUser =-1 I = 0' Initialize loop counter Do While i
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.