An array is a collection of values of same data type.
(1) Declaring a Single dimension Integer Array
Dim Arr(4) as Integer
Assigning values to that array.
Arr(0) = 10
The array element starts with zero, so we can store up to 5 integer containing 0 to 4 elements.
Create Array with initialize
Dim Arr() as integer = New Integer (4) {}
βNew Integer (4)β statement will create an integer array with 0 to 4 elements. β{}β Will initialize the array after creation.
(2) Two-dimensional array.
Dim TArr(3,3) as Integer
Assigning values to the array.
TArr(0,0) =2
We can store up to 16 values in this 3,3 Integer array.
Dim TArr( , ) as Integer = New Integer(2,2) {}
(3) Resizing an Array
We can resize the array element using ReDim statement.
ReDim Arr(12)
The above statement resizes the array element size to 13.
ReDim Preserve Arr(12)
We can use Preserve keyword to resize only size of the array. It will not affect existing content of an array.
|
| Author: Richard G Bean 14 Jul 2004 | Member Level: Bronze Points : 0 |
Does the comment: "We can store up to 16 values in this 3,3 Integer array." Refer to the original declaration: "Dim TArr(3,3) as Integer" or the line immediately following it?: "Dim TArr( , ) as Integer = New Integer(2,2) {}"
If it refers to the first, what does the line below the comment have to do with anything? I just think that this section needs a bit more clarification.
Rick
|