How to VB.Net Arrays
Arrays are using for store similar data types grouping as a single unit. We can access Array elements by its numeric index.
Dim week(6) As String
The above Vb.Net statements means that , an Array named as week declared as a String type and it can have the capability of seven String type values.
week(0) = "Sunday"
week(1) = "Monday"
In the above statement , we initialize the values to the String Array. week(0) = "Sunday" means , we initialize the first value of Array as "Sunday" ,
Dim weekName as String = week(1)
We can access the Arrays elements by providing its numerical index, the above statement we access the second value from the week Array.
In the following program , we declare an Array "week" capability of seven String values and assigns the seven values as days in a week . Next step is to retrieve the elements of the Array using a For loop. For finding the end of an Array we used the Length function of Array Object.
VB.NET SourceCode
When you execute this program you will get the Days in a Week .
|