State a circumstance under which each of the following statements are used in a visual basic program: (6 marks)
(i) ReDim;
(ii) Option base;
(iii) Preserve.
Answer:
ReDim
Circumstance: The ReDim statement is used to resize an existing array while preserving its existing values or to initialize a dynamic array.
Option Base
Circumstance: The Option Base statement is used to set the default lower bound for arrays. By default, arrays in Visual Basic are zero-based (i.e., the first element is at index 0). Option Base allows changing the default lower bound to 1.
Preserve
Circumstance: The Preserve keyword is used in conjunction with ReDim to resize an array while preserving its existing values.