A data structure in which individual values (called elements or items) may be located by reference to one or more integer index variables, the number of such indices being the number of dimensions in the array.
Arrays can start with an index value of 0 or 1, sometimes referred to as 0 based or 1 based.
Access VBA:
x = Array()
Arrays in Access VBA use a 0-based indice. Use UBound to get the number of elements. UBound returns -1 if the array has no elements, 0 if it has 1, 1 if it has 2, etc.
The following are practice certification questions with answers highlighted. These questions were prepared by Mike Prestwood and are intended to stress an important aspect of this KB post. All our practice questions are intended to prepare you generally for passing any certification test as well as prepare you for professional work.
The following are practice certification questions with answers highlighted. These questions were prepared by Mike Prestwood and are intended to stress an important aspect of this KB post. All our practice questions are intended to prepare you generally for passing any certification test as well as prepare you for professional work.
Arrays in ObjectPAL use a 1-based subscript (also known as an index). Use [] with a subscript to refer to an element (i.e. MyArray[1], MyArray[2]).
The number of elements for a given array in ObjectPAL are either fixed or resizeable. Specify the size when you declare it for fixed. Use size() to get the number of elements, size() returns 0 if the array has no elements. Use setSize(), grow(), addLast(), etc. to add elements to an array.
Syntax Example:
var MyArray Array[4] String ;Fixed size array. i LongInt endVar
The following are practice certification questions with answers highlighted. These questions were prepared by Mike Prestwood and are intended to stress an important aspect of this KB post. All our practice questions are intended to prepare you generally for passing any certification test as well as prepare you for professional work.
Because you can specify both he upper and lower index values when you declare a static array, you can specify 0 or 1 as the base index value. For example, you can rewrite the above code as:
var MyArray: array[1..4] of string; i: Integer; begin MyArray[1] := 'Mike'; MyArray[2] := 'Lisa'; MyArray[3] := 'Felicia'; MyArray[4] := 'Nathan';
for i := Low(MyArray) to High(MyArray) do ShowMessage(MyArray[i]); end;
Note the use of Low() in place of the base index value in the for loop.
In fact, you could specify any range you wish,
MyArray: array[6..9] of string;
or even:
MyArray: array[-1..2] of string;
You can also use an ordinal type such as Word or Byte directlry. For exaple, because a Byte is equivalent to 0..255 the following:
MyArray: array[Byte] of string;
is equivalent to:
MyArray: array[0..255] of string;
Initialize Global Arrays
You can initialize the values of a global array when you declare it, but not a local array. For example, the following code snippet is in the interface section of a unit.
var Form2: TForm2; MyArray2: array[0..1] of string = ('Mike', 'Lisa');
The following are practice certification questions with answers highlighted. These questions were prepared by Mike Prestwood and are intended to stress an important aspect of this KB post. All our practice questions are intended to prepare you generally for passing any certification test as well as prepare you for professional work.
Arrays in VB Classic use a 0-based indice. Use UBound to get the number of elements. UBound returns -1 if the array has no elements, 0 if it has 1, 1 if it has 2, etc.
The following are practice certification questions with answers highlighted. These questions were prepared by Mike Prestwood and are intended to stress an important aspect of this KB post. All our practice questions are intended to prepare you generally for passing any certification test as well as prepare you for professional work.