Changes

Jump to: navigation, search

Visual Basic Arrays

No change in size, 19:22, 9 April 2009
no edit summary
== What is a Visual Basic Array ==
<google>ADSDAQBOX_FLOW</google>
A Visual Basic array is an object that contains a specified number of variables of teh the same type. Once you have grouped all the variable values into the array you can then perform tasks like sorting the array items into alphabetical or numerical order, accessing and changing the value assigned to each array item, and passing the group of items as a parameter to a Visual Basic Function or Subroutine (see [[Visual Basic Modules and Procedures]]) by passing just the array object.
In this chapter we will look in detail at how to create and manipulate single Visual Basic arrays. The next chapter will cover [[Visual Basic Multidimensional Arrays]].
'''Dim''' ''arrayname(size)'' '''As''' ''dataType''
The ''arrayname'' is the name by which the array will referenced in code. The ''size'' value in parentheses defines the maximum size of the array. It is important to note that arrays array elements are numbered starting from 0, so an array of size 10 actually holds 11 elements (indexed as 0 though to 10).
Finally, the ''dataType'' value defines the type of variable the array will hold.
== Finding the Size of an Array ==
The size of an array (i.e . the number of elements contained in the array) can be obtained by accessing the ''Length'' property of the specific array.
For example, to find out the size of the strColors array:
</pre>
The Visual Basic ''Array.Reverse()'' function may be used to reverse the order of elements in an array. it It is particularly useful to call this function after calling the ''Array.Sort()'' function to sort elements into reverse order:
<pre>

Navigation menu