In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly explains "VBScript variable". Interested friends may wish to take a look at it. The method introduced in this paper is simple, fast and practical. Next, let the editor take you to learn the "VBScript variable"!
VBScript variable
A variable is an easy-to-use placeholder that refers to the computer's memory address, which 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 the variable in computer memory to use the variable. You can view or change the value of the variable simply by referencing it through its name. There is only one basic data type in VBScript, Variant, so the data type of all variables is Variant.
Declare variable
One way to declare variables is to explicitly declare variables in a script using Dim statements, Public statements, and Private statements. For example:
Dim DegreesFahrenheit
When declaring multiple variables, separate the variables with commas. For example:
Dim Top, Bottom, Left, Right
Another way is to implicitly declare variables by using variable names directly in the script. This is usually not a good habit because it can sometimes lead to unexpected results when running scripts due to misspelled variable names. Therefore, it is best to use the Option Explicit statement to explicitly declare all variables as the first statement of the script.
Naming rules
Variable naming must follow the standard naming conventions of VBScript. 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.
The scope and survival period of variables
The scope of a variable is determined by where it is declared. If you declare a variable in a procedure, only the code in the procedure can access or change the value, where the variable has a local scope and is called a procedure-level variable. If a variable is declared outside a procedure, it can be recognized by all procedures in the script, called a Script-level variable, and has script-level scope.
The time for which a variable exists is called a survival period. The lifetime of a Script-level variable is from the moment it is declared to the end of the script. For a process-level variable, its lifetime is only the time the process is running, and when the process ends, the variable disappears. Local variables are ideal temporary storage space when executing a procedure. Local variables with the same name can be used in different procedures because each local variable is identified only by the process that declares it.
Assign a value to a variable
Create an expression in the following form to assign a value to a variable: the variable is on the left side of the expression, and the value to be assigned is 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 more convenient to assign multiple related values to a single variable, so you can create a variable that contains a series of values, called an array variable. Array variables and scalar variables are declared in the same way, except that the variable name is followed by parentheses () when declaring array variables. The following example declares an one-dimensional array of 11 elements:
Dim A (10)
Although the number shown in parentheses is 10, because all arrays in VBScript are based on 0, this array actually contains 11 elements. In a 0-based array, the number of array elements is always the number shown in parentheses plus 1. Such an array is called a fixed-size array.
Use an index in an array to assign values 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, the data of the desired array elements can be retrieved using the index. For example:
. . .
SomeVariable = A (8)
. . .
Arrays are not limited to one dimension. The maximum dimension of an array can be 60 (although most people cannot understand a dimension greater than 3 or 4). When declaring a multidimensional array, separate each number in parentheses that represents the size of the array with a comma. 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 represents the number of rows and the second number represents the number of columns.
You can also declare dynamic arrays, that is, arrays that change in size when the script is run. Use Dim or ReDim statements for the initial declaration of the array. For dynamic arrays, however, there are no numbers in parentheses. For example:
Dim MyArray ()
ReDim AnotherArray ()
To use dynamic arrays, you must then use ReDim to determine the dimension and the size of each dimension. In the following example, ReDim sets the initial size of the dynamic array to 25, while the subsequent ReDim statement resizes the array to 30, while using the Preserve keyword to retain the contents of the array when resized.
ReDim MyArray (25)
. . .
ReDim Preserve MyArray (30)
There is no limit to the number of times you can resize a dynamic array. If you resize the array for an hour, you will lose the data of the deleted element.
At this point, I believe that you have a deeper understanding of the "VBScript variable", might as well come to the actual operation of it! Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
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.