![]() |
VB.Net Array Basics
On 6th May, 2007
|
Recent Articles
Similar Articles
Purpose of the arrays Arrays are generally used for storing similar types of values or objects. They allow grouping variables together and allow referring to them by using an index. Arrays have an upper bound and a lower bound, which simply refer to the starting index and the ending index of a given array structure. Additionally, the data in the array can be sorted. Simple arrays are one-dimensional; however, you can also use multi-dimensional arrays in VB.NET. You can loop through an array to determine and to modify the values stored in the array. Declaring and initialising arrays There are two ways of initialising the arrays: to declare and initialise them in one statement, or to declare an array and choose to initialise it later. When declaring and initialising arrays in the same statement, you must specify the type of the array elements and the number of the elements the array will hold. In VB.NET, arrays are zero based, which means that the index of the first element is zero. The elements are numbered sequentially. You must specify the number of array elements by indicating the upper bound of the array. The upper bound is the number that specifies the index of the last element in the array. Snippet A shows the declaration and initialisation of an array of integers. Snippet A Code: VB.Net
Snippet B Code: VB.Net
Snippet C Code: VB.Net
Snippet D Code: VB.Net
|
|
|
#2 |
|
Contributor
Join Date: Apr 2009
Posts: 53
Thanks: 0
Thanked 1 Time in 1 Post
Rep Power: 1 ![]() |
Re: VB.Net Array Basics
The keywords 'ReDim' & 'Preserve' are really helpful! Coz I just knew to use the Array in Snippet A & B. Thx |
|
|
|
|
|
#3 |
|
Contributor
Join Date: Apr 2009
Posts: 53
Thanks: 0
Thanked 1 Time in 1 Post
Rep Power: 1 ![]() |
Re: VB.Net Array Basics
in the snippet D, is it just 'ReDim Preserve arrNumbers (25)'? no '...As Integer'? |
|
|
|
|
|
#4 |
|
Newbie Member
Join Date: Oct 2009
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0 ![]() |
Re: VB.Net Array Basics
Thanks for dharing your ideas to us...
|
|
|
|
![]() |
|
| Currently Active Users Reading This Article: 1 (0 members and 1 guests) | |
| Article Tools | Search this Article |
| Display Modes | |
| Bookmarks | |
|
|
|
|||||||||||||||||||||||||||||||||||||