VB.Net-Informations.com
   Home      .Net Framework      VB.NET      C#                                                                      About


  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 Source Code Download           Print Source Code
         How to VB.Net Arrays - Download
        
C# Tutorial

Public Class Form1
    Private Sub Button1_Click(ByVal sender As System.Object, _
    ByVal e As System.EventArgs) Handles Button1.Click
        Dim i As Integer
        Dim week(6) As String
        week(0) = "Sunday"
        week(1) = "Monday"
        week(2) = "Tuesday"
        week(3) = "Wednesday"
        week(4) = "Thursday"
        week(5) = "Friday"
        week(6) = "Saturday"

        For i = 0 To week.Length - 1
            MsgBox(week(i))
        Next

    End Sub
End Class

When you execute this program you will get the Days in a Week .

VB.NET Collections Related Contents
*     How to use VB.NET ArrayList
*     How to use VB.NET HashTable
*     How to use VB.NET Stack
*     How to use VB.NET Queue
*     How to use VB.NET Dyanamic Arrays
*     How to use VB.NET NameValueCollection


   Home      VB.NET      C#
VB.Net Related Topics
*     Microsoft .Net Framework Tutorials
*     VB.NET Language Basics Tutorials
*     VB.NET Program Flow Control Tutorials
*     VB.NET Collections Tutorials
*     VB.NET String Tutorials
*     VB.NET Files Tutorials
*     VB.NET Excel 2007 Tutorials
*     VB.NET Crystal Reports Tutorials
*     VB.NET Communications Tutorial
*     VB.NET ADO.NET Tutorial
*     ADO.NET Data Providers help and Tutorial
*     VB.NET ADO.NET Dataset Tutorial
*     ADO.NET DataAdapter and Dataset
*     VB.NET ADO.NET DataView Tutorial
*     VB.NET Remoting Tutorial
*     VB.NET XML Tutorial
*     VB.NET DataGridView Tutorial
   Home      VB.NET      C#
More Source Code :   
Mail to :  feedback@net-informations.com
  |  Home   |  VB.NET   |  C#   |  SiteMap   |  Terms of Use   |  About   |
net-informations.com (C) 2010
All Rights Reserved. All other trademarks are property of their respective owners.