Arrays in Vbscript Essay

3211 Words13 Pages
Arrays in VBScript Unlike all the other subtypes I showed you last month, an array can hold more than one value. An array lets you address many data values through the same variable. Think of an array as a list (e.g., a list of usernames). You reference each item in this list with a common name and index number. The common name is the name of the array variable. The common name typically includes the prefix arr to denote that the variable contains data of the subtype Array. The index number is an integer subscript that denotes an item's relative location in the list. The indexes always increment sequentially, starting from 0. For example, if an array has three items, the indexes are 0, 1, and 2. The 0 index represents the first position, the 1 index represents the second position, and the 2 index represents the third position in the array. You can create two types of arrays: static and dynamic. Static arrays stay a fixed size throughout their lifetime—that is, the index size remains constant. Thus, when you create a static array, you must know how many items the array will contain throughout its lifetime. If you don't know this information or you know that the array's index size will change, you need to create a dynamic array. Dynamic arrays don't have a fixed index size. You can increase or decrease the index size at any time. Creating Arrays You can create arrays several ways, depending on whether they are static or dynamic. To create a static array, you use a Dim statement with the array's common name, such as ------------------------------------------------- Dim arrGroc(2) The number in parentheses specifies the maximum value of indexes in the array. The value of 2 denotes that the array's indexes range from 0 to 2, which means the array can contain up to three items. In other words, 2 is the array's upper bound. Arrays also have a

More about Arrays in Vbscript Essay

Open Document