Checking a non ReDim:ed array?

  • Thread starter Thread starter Niklas Östergren
  • Start date Start date
N

Niklas Östergren

Hi!

Is it possible to check either the value of an array that hasn´t been
ReDim:ed yet. OR is it possible to check IF an array have been ReDim:ed and
appended data or not?

I´m using a global array which I ReDim:ed and append data to IF a table have
any records. Sometimes the table do NOT and if so I don´t ReDim the array
since it´s not going to be used.

The array is used in a wizard to store the primary key´s for newly added
records and if the user deside to go to the previous form or abort the
wizard then I have to know which records I need to delete, which is the
records with the primary key´s stored in the global array.

One way I could do is offcourse is to allways ReDim the array to ReDim
glngarrFamilyMemberID(1) and then append data glngarrFamilyMemberID(0) = 0
and then when I need it I ReDim it again and do NOT Preserve stored data.
Since this make´s it possible for med to check if index 0 of the array
contain´s 0 or someting else.

Or maby some of you have any better idé of how I shall solve this?

But my Q right now is:
1.) Is it possible to check if an array have been ReDim:ed or not?

TIA!
// Niklas
 
Niklas Östergren said:
Hi!

Is it possible to check either the value of an array that hasn´t been
ReDim:ed yet. OR is it possible to check IF an array have been
ReDim:ed and appended data or not?

I´m using a global array which I ReDim:ed and append data to IF a
table have any records. Sometimes the table do NOT and if so I don´t
ReDim the array since it´s not going to be used.

The array is used in a wizard to store the primary key´s for newly
added records and if the user deside to go to the previous form or
abort the wizard then I have to know which records I need to delete,
which is the records with the primary key´s stored in the global
array.

One way I could do is offcourse is to allways ReDim the array to ReDim
glngarrFamilyMemberID(1) and then append data
glngarrFamilyMemberID(0) = 0 and then when I need it I ReDim it again
and do NOT Preserve stored data. Since this make´s it possible for
med to check if index 0 of the array contain´s 0 or someting else.

Or maby some of you have any better idé of how I shall solve this?

But my Q right now is:
1.) Is it possible to check if an array have been ReDim:ed or not?

There are a couple of ways, including applying the UBound or LBound
function to the array and trapping the error that will result if the
array hasn't been allocated, or else actually peeking at the memory
location referenced by the array name. However, I think the simplest
way is just to have a global flag variable declared along with the
array, set this variable to True when you ReDim the array, and test the
variable when you want to know if the array has been allocated.
 
Thank´s a lot Dirk!

That seams simple enough so I´ll go for the flag solution!

// Niklas
 
Hi Niklas,

Off-thread for this question, but since you appear to be able to monitor this message.....
Just curious if you were able to see my answer to your post "Validation Problem" from last week.
You had posted the question 3 times, and indicated that you didn't see any answers.


Tom
____________________________


Thank´s a lot Dirk!

That seams simple enough so I´ll go for the flag solution!

// Niklas
 
Hi Tom!
Yes finaly I could monitor the third post. Why I could´nt see it I don´t
know. I tryed from three different pc:s with two different internet
connections. And after trying to post it from my pc at home with a simple
56kb modem it worked. Strange!

Thank´s for helping out though!

// Niklas
 
Back
Top