Recent Articles
- Drag Drop FROM VB.net TO Windows Explorer, Started by ManzZup in Visual Basic [VB]
- Simple Calculator in Visual Basic 6, Started by shabbir in Visual Basic [VB]
- Handling the large numeric values while exporting to excel., Started by sameer_havakajoka in Visual Basic [VB]
- Printing Text Directly To Default Printer, Started by naimish in Visual Basic [VB]
- Visual Baisc RPG attack combat system script Tutorial, Started by XXxxImmortalxxXX in Visual Basic [VB]
Similar Articles
- Arrays in Visual basic, Started by Sanskruti in Visual Basic [VB]
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
Dim arrNumbers(4) As Integer 'Declares & initialises an array of 5 integers, with indexes ranging from 0 to 4
Snippet B
Code: VB.Net
Dim arrNumbers() As Integer 'Declares the array of integers
arrNumbers = New Integer() {0,1,2,3,4} 'Initialises the array to five members & sets their values
Snippet C
Code: VB.Net
Dim arrNumbers(32) As Integer' Declares & Initialises an array of integers
ReDim arrNumbers(45) As Integer' Re-initialises the array
Snippet D
Code: VB.Net
Dim arrNumbers () As Integer = {0,1,2,3,4}' Declares & initialises the array
ReDim Preserve arrNumbers (25) 'Resizes the array, but retains the data in elements 0 through 4











Yet to provide details about himself


Linear Mode

