Lars Brownie said:
For example: I have an array with the following stringvalues: "one",
"two", "four". Between the "two" and "four" I would like to insert value
"three". The order is important as I have to 'scan' through the array in
that particular order. Can this be done?
You can do this, but I likely have to ask why you need such a design?
You have this high speed database engine, and we now back to coding and
inserting values into an array that we need to somehow order, and then
additionally write code to search?
Furthermore, where did the original 1-3 values come from? (perhaps the
values should be placed in a table?????).
Something just don't jive right here. In stead of matching a whole bunch of
values against a array in a loop, why not tell the database engine to match
the one value???
Anyway, *if* you must really go back to the punched card days of FORTRAN and
use a array, then you must:
1) redimenstion the array (using the preserve word to keep existing values)
to increase the size of the array by one.
eg:
Dim MyArray() As Integer
Dim j As Integer
ReDim MyArrary(4)
....increase to 5
ReDim Preserve MyArray(5)
note that you MUST declare the array with () (no value) to be able to re-dim
the array
on the fly in code.
2) write a loop to move everything down by one at the spot you need to
insert the value
eg:
move everything up from 3 to 5, make a hole in 2
for j = 5 to 3
MyArrary(j) = MyArrary(j-1)
next j
3) insert the value
MyArrary(2) = new value
I should point out that by default, arrays are *zero* based in access (they
start at zero).
Really, I been writing code in access for a LONG time, and I NEVER had to
use a an array as such. Arrays are just not really for dataprocessing
anymore...and I suspect some type of table based approach here would like
save some good amounts of developer time here....
If the data in the array is read only, then using a collection likely would
be more useful. However, it not clear how/where the original values came
from, and how these values got their way into the array in the first place.