Get the App
SLTechnology News&Howtos  ›  Development  › 

The usage of ReDim statement in VBS

Shulou Source: shulou.com Published: 2022-06-03 19:37:52 09月30日 Update

This article mainly explains "the usage of ReDim sentence in VBS". The content of the explanation in this article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn the usage of ReDim sentence in VBS.

Declare dynamic array variables at the procedure level and allocate or reallocate storage space.

ReDim [Preserve] varname (subscripts) [, varname (subscripts)]. . .

Parameter Preserve

Preserves data when changing the size of the last dimension of an existing array.

Varname

Variable name, following the standard variable naming convention.

Subscripts

The dimension of array variables, up to 60-dimensional arrays can be declared. The syntax format of the subscripts parameter is as follows:

Upper [, upper]. . .

The lower bound of the array is always zero.

Description

ReDim statements are typically used to specify or modify the size of dynamic arrays that have been formally declared with Private, Public, or Dim statements with empty parentheses (without dimensional subscripts). You can use the ReDim statement repeatedly to change the array dimension and the number of elements.

If you use the Preserve keyword, you can only resize the last dimension of the array, and you cannot change the dimension of the array. For example, if the array has only one dimension, you can modify the size of the array because that dimension is the last and only one. However, if the array has two or more dimensions, you can only change the size of the last dimension and retain the contents of the array.

This example shows how to increase the termination dimension of a dynamic array without erasing the data that exists in the array.

ReDim X (10,10,10). . Redim Preserve X (10, 10, 15) be careful that if you reduce the size of the array, you will lose the data in the excluded elements.

When the variable is initialized, the numeric variable is initialized to 0 and the string variable is initialized to a zero-length string ("). Before you can use a variable that references an object, you must use the Set statement to assign an existing object to the variable. Before object assignment, declared object variables have a specific value of Nothing.

Thank you for reading, the above is the content of "the usage of ReDim sentence in VBS". After the study of this article, I believe you have a deeper understanding of the usage of ReDim sentence in VBS, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Tags: Array variable statement size object content dynamic data one-dimensional learning element parameter character string more allocation subscript lower bound two examples Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno NVidia OPPO Reno Shulou Tech Info Linux Microsoft