-
A variable is an amount that can be changed within a defined range and is used to store the value of a parameter.
1) Naming conventions for variables.
1) Must start with a letter or Chinese character, consisting of letters, Chinese characters, numbers or underscores, and be 255 characters long;
2) Do not use keywords in vb, and try not to have the same name as the standard function name in vb; Such as: dim, sin
3) VB does not distinguish between the case of variables, and the first letter of the general variable is uppercase, and the rest are lowercase;
4) In order to increase the readability of the program, an abbreviated prefix can be added to the variable name to indicate the data type of the variable.
2) Variable declarations.
1) Make explicit declarations with dim statements.
Statement form: dim variable name [as type] e.g. dim intx as integer
Note: If there is no AS type, it defaults to a variant type.
You can add a type symbol to the end of the variable name instead of the as type, for example: dim intx%.
A statement can define multiple variables at the same time, but each variable must have its own type declaration, and type declarations cannot be shared.
String variables are defined differently depending on whether they are stored at a fixed length or not:
Fixed-length string: dim stra as string*10
It means that a maximum of 10 characters can be stored, and if the assignment is less than 10, the right fills the blank. If there are more than 10, the excess part will be cut off.
Indefinite-length strings: dim stra as string 'can store up to 2MB characters.
Description: DIM life variables, valid in the modules or processes of their lives; The variable of private life is equivalent to the range of dim; The variables of public life are valid throughout the project.
2) Implicit declarations.
VB allows variables to be used without declaration, which is called implicit declaration, and all implicitly declared variables are variants.
Implicit declarations are easy to cause errors, for the convenience of debugging programs, the variables used are generally declared, and the option explicit statement can be used in the generic declaration section to force all variables to be declared explicitly.
3) Assignment. Use the assignment number "=".
e.g. dim a as integer
a = 8 or: a = 2 + 3
-
Variable is the "bowl" used to "hold" data, the statement that defines the variable is dim xx as is the variable name, yy is the data type, for example, the string type can store the text, the integer type can store the number, etc., set the variable: variable name = value (e.g. abc=16) If the type is object, it should be defined by set, such as set w = createobject("")
-
Normal variables:
Variable = Value.
Object variable: set variable = object.
a = "n c hundred du q49232 ah ah ah pp"
mid(trim(a), 9, 5) 'From the 9th character from left to right (spaces are also counted), count 5 characters you want. >>>More
A practical clipboard is all it takes.
Some of the content is posted to filtering.,Please see ** for incomplete content.。 >>>More
tooltiptext property.
Go back or set a tooltip. >>>More
Oh! Cake sellers! In the case of the same color mode, please change the color settings of the two software to the same, and the colors will match! ~