- ✕This summary was generated using AI based on multiple online sources. To view the original source information, use the "Learn more" links.
In VBScript, an array is a variable that can hold multiple values at once. This is useful when you need to store a series of values in a single variable. Arrays in VBScript can store any type of variable, including integers, strings, and dates.
Declaring Arrays
Arrays are declared similarly to variables, but with parentheses to indicate the size. Here are three ways to declare an array:
' Method 1: Using Dim without sizeDim arr1()' Method 2: Mentioning the sizeDim arr2(5) ' Declared with size of 5' Method 3: Using Array functionDim arr3arr3 = Array("apple", "Orange", "Grapes")Copied!✕CopyAssigning Values to an Array
Values are assigned to an array by specifying the index. Here is an example:
Dim arr(5)arr(0) = "1" ' Number as Stringarr(1) = "VBScript" ' Stringarr(2) = 100 ' Numberarr(3) = 2.45 ' Decimal Numberarr(4) = #10/07/2013# ' Datearr(5) = #12.45 PM# ' Time' Displaying valuesdocument.write("Value stored in Array index 0: " & arr(0) & "<br />")document.write("Value stored in Array index 1: " & arr(1) & "<br />")document.write("Value stored in Array index 2: " & arr(2) & "<br />")document.write("Value stored in Array index 3: " & arr(3) & "<br />")document.write("Value stored in Array index 4: " & arr(4) & "<br />")document.write("Value stored in Array index 5: " & arr(5) & "<br />")Copied!✕Copy VBScript Variables, Arrays - with VBScript
SponsoredSend, receive and monitor data. RS232, RS485, TCP, UDP, HID & more.Edit Send Sequence · Advanced data detection · Reference Material
VBScript Array Function - W3Schools
Learn how to use the Array function to create and manipulate arrays in VBScript. See syntax, parameters, examples and output of the function.
- People also ask
VBScript Arrays: Using DIM, REDIM, Split, and Ubound …
Apr 1, 2025 · Learn how to declare, assign, and use arrays in VBScript, a scripting language for Windows. Find out the types, functions, and keywords of arrays, such as DIM, REDIM, Split, and Ubound.
How does one declare an array in VBScript? - Stack Overflow
VBScript's (variables and) arrays can't be typed, so no "as Whatever". VBscript's arrays are zero-based, so no " (x To y)" but only " (z)" where z is the last index (not the size) of the array.
- Reviews: 1