8.3. Declaring and Allocating Arrays

Arrays occupy space in memory. The amount of memory required by an array depends on the length of the array and the size of the type of the elements in the array. To declare an array, provide the array’s name and type. Either of the following statements can be used to declare the array in Fig. 8.1:

					Dim c As Integer()
Dim c() As Integer
				

The parentheses that follow the type indicate that c is an array. Arrays can be declared to contain elements of any type; every element of the array is of that type. For example, every element of an Integer array contains an Integer value.

Before an array can be used, you must specify the size of the array and allocate memory for the array, using keyword New. Recall from ...

Get Visual Basic 2005 for Programmers: Deitel Developer Series, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.