C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




How to use Array in VB.NET.


Posted Date: 12 Mar 2004    Resource Type: Articles    Category: .NET Framework
Author: KasiviswanathMember Level: Gold    
Rating: Points: 10



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.




Responses

Author: Richard G Bean    14 Jul 2004Member 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



Feedbacks      
Popular Tags   What are tags ?   Search Tags  
(No tags found.)

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Retrieving the name of the current method
Previous Resource: Working with Inner Class in VB.Net
Return to Discussion Resource Index
Post New Resource
Category: .NET Framework


Post resources and earn money!
 
Related Resources



dotNet Slackers   BizTalk Adaptors    Web Design


Contact Us    Privacy Policy    Terms Of Use