In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly introduces "what is a VBScript variable". In daily operation, I believe many people have doubts about what is a VBScript variable. Xiaobian consulted all kinds of information and sorted out simple and easy to use operation methods. I hope to help you answer the doubts about "what is a VBScript variable"! Next, please follow the small series to learn together!
VBScript variables
A variable is a handy placeholder for referring to a computer memory address that stores program information that can be changed while the script is running. For example, you can create a variable called ClickCount to store the number of times a user clicks an object on a Web page. You don't need to know the address of a variable in computer memory to use it; you can view or change its value by referring to it by its name. In VBScript there is only one primitive data type, Variant, so all variables have Variant data types.
declare variables
One way to declare variables is to explicitly declare them in scripts using Dim, Public, and Private statements. For example:
Dim DegreesFahrenheit
When declaring multiple variables, separate variables with commas. For example:
Dim Top, Bottom, Left, Right
Another way is to implicitly declare variables by simply using the variable name directly in the script. This is usually not a good habit because it can sometimes cause unexpected results when running scripts due to misspelled variable names. Therefore, it is best to explicitly declare all variables using the Option Explicit statement as the first statement of the script.
naming rules
Variable naming must follow VBScript's standard naming conventions. Variable naming must follow:
The first character must be a letter.
Cannot contain embedded periods.
The length cannot exceed 255 characters.
Must be unique within the declared scope.
Scope and Survival of Variables
The scope of a variable is determined by where it is declared. If a variable is declared in a procedure, only code in that procedure can access or change the magnitude, in which case the variable has local scope and is called a procedure-level variable. If a variable is declared outside of a procedure, it is recognized by all procedures in the script and is called a script-level variable with script-level scope.
The time a variable exists is called the survival period. Script variables have a lifetime from the moment they are declared until the end of script execution. For a process-level variable, its lifetime is simply the time the process runs, and when the process ends, the variable disappears. Local variables are ideal temporary storage spaces when executing procedures. Local variables with the same name can be used in different procedures because each local variable is recognized only by the procedure that declares it.
assign values to variables
Create an expression to assign values to variables of the form: variables on the left side of the expression and values to be assigned on the right side of the expression. For example:
B = 200
Scalar variables and array variables
In most cases, you only need to assign a value to the declared variable. Variables that contain only one value are called scalar variables. Sometimes it is convenient to assign multiple related values to a variable, so you can create variables that contain a series of values, called array variables. Array variables and scalar variables are declared in the same way, the only difference being that array variables are declared with parentheses ( ) after the variable name. The following example declares a one-dimensional array of 11 elements:
Dim A(10)
Although the number shown in parentheses is 10, since all arrays in VBScript are zero-based, this array actually contains 11 elements. In zero-based arrays, the number of array elements is always the number shown in parentheses plus 1. Such arrays are called fixed-size arrays.
Use an index in an array to assign a value to each element of the array. From 0 to 10, assign data to the elements of the array as follows:
A(0) = 256
A(1) = 324
A(2) = 100
. . .
A(10) = 55
Similarly, indexes can be used to retrieve data for the desired array element. For example:
. . .
SomeVariable = A(8)
. . .
Arrays are not limited to one dimension. Arrays can have up to 60 dimensions (although most people don't understand dimensions beyond 3 or 4). Declare multidimensional arrays with commas separating the numbers in parentheses that each represent the size of the array. In the following example, the MyTable variable is a two-dimensional array with 6 rows and 11 columns:
Dim MyTable(5, 10)
In a two-dimensional array, the first number in parentheses indicates the number of rows and the second number indicates the number of columns.
You can also declare dynamic arrays, which change in size as the script runs. Use a Dim statement or ReDim statement for the initial declaration of an array. But for dynamic arrays, the parentheses don't contain any numbers. For example:
Dim MyArray()
ReDim AnotherArray()
To use dynamic arrays, you must then use ReDim to determine the dimensions and size of each dimension. In the following example, ReDim sets the initial size of the dynamic array to 25, and the following ReDim statement resizes the array to 30, while using the Preserve keyword to preserve the contents of the array during resizing.
ReDim MyArray(25)
. . .
ReDim Preserve MyArray(30)
There is no limit to the number of times a dynamic array can be resized. Resizing the array will result in the loss of data for deleted elements.
At this point, the study of "what is a VBScript variable" is over, hoping to solve everyone's doubts. Theory and practice can better match to help you learn, go and try it! If you want to continue learning more relevant knowledge, please continue to pay attention to the website, Xiaobian will continue to strive to bring more practical articles for everyone!
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.