Find more freelance jobs
|
Some times you want to assign more than one value to a single variable. Then you can create a variable that can contain a series of values. This is called an array variable. The declaration of an array variable uses parentheses ( ) following the variable name. In the following example, an array containing 3 elements is declared: dim names(2) The number shown in the parentheses is 2. We start at zero so this array contains 3 elements. This is a fixed-size array. You assign data to each of the elements of the array like this: names(0) = "Tove" names(1) = "Jani" names(2) = "Ståle" Similarly, the data can be retrieved from any element using an index into the particular array element you want. Like this: mother = names(0) You can have up to 60 dimensions in an array. Multiple dimensions are declared by separating the numbers in the parentheses with commas. Here we have a two-dimensional array consisting of 5 rows and 7 columns: dim table(4, 6) VBScript Procedures We have two kinds of procedures: The Sub procedure and the Function procedure. A Sub Procedure: · Is a series of statements, enclosed by the Sub and End Sub statements · Perform actions, but do not return a value · Can take arguments that are passed to it by a calling procedure · Without arguments, must include an empty set of parentheses () Sub mysub() some statements End Sub The Function Procedure · Is a series of statements, enclosed by the Function and End Function statements · Perform actions, but can also return a value · Can take arguments that are passed to it by a calling procedure · Without arguments, must include an empty set of parentheses () · Returns a value by assigning a value to its name Function myfunction() some statements myfunction = some value End Function |